public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: wangshuo_1994@foxmail.com
To: libc-alpha@sourceware.org, samuel.thibault@ens-lyon.org
Cc: abushwang <wangshuo_1994@foxmail.com>
Subject: [PATCH] hurd fcntl: remove duplicate do...while in LOCKED macro
Date: Wed,  4 Jan 2023 18:30:57 +0800	[thread overview]
Message-ID: <tencent_6AE67FD99D9CE0D5E6F93FFF6CE49CED1E09@qq.com> (raw)

From: abushwang <wangshuo_1994@foxmail.com>

commit e1a467d introduces do...while for LOCKED macro. However, there is
already while(0) in LOCKED macro according to HURD_CRITICAL_END in hurd/hurd/signal.h:

    #define HURD_CRITICAL_BEGIN \
      { void *__hurd_critical__ = _hurd_critical_section_lock ()
    #define HURD_CRITICAL_END \
          _hurd_critical_section_unlock (__hurd_critical__); } while (0)

It is robust enough.

Signed-off-by: abushwang <wangshuo_1994@foxmail.com>
---
 sysdeps/mach/hurd/fcntl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c
index 48608493a1..ea35e9b977 100644
--- a/sysdeps/mach/hurd/fcntl.c
+++ b/sysdeps/mach/hurd/fcntl.c
@@ -109,7 +109,7 @@ __libc_fcntl (int fd, int cmd, ...)
 
       /* Set RESULT by evaluating EXPR with the descriptor locked.
 	 Check for an empty descriptor and return EBADF.  */
-#define LOCKED(expr) do {						      \
+#define LOCKED(expr)							      \
       HURD_CRITICAL_BEGIN;						      \
       __spin_lock (&d->port.lock);					      \
       if (d->port.port == MACH_PORT_NULL)				      \
@@ -117,8 +117,7 @@ __libc_fcntl (int fd, int cmd, ...)
       else								      \
 	result = (expr);						      \
       __spin_unlock (&d->port.lock);					      \
-      HURD_CRITICAL_END;						      \
-} while(0)
+      HURD_CRITICAL_END;
 
     case F_GETFD:		/* Get descriptor flags.  */
       LOCKED (d->flags);
-- 
2.37.3


             reply	other threads:[~2023-01-04 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 10:30 wangshuo_1994 [this message]
2023-01-04 11:56 ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_6AE67FD99D9CE0D5E6F93FFF6CE49CED1E09@qq.com \
    --to=wangshuo_1994@foxmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=samuel.thibault@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).