From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 9E6EF3858C2D for ; Wed, 4 Jan 2023 11:56:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E6EF3858C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 9AEE320149; Wed, 4 Jan 2023 12:56:52 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xSZ9hzAMQObA; Wed, 4 Jan 2023 12:56:51 +0100 (CET) Received: from begin (nat-inria-interne-52-gw-01-bso.bordeaux.inria.fr [194.199.1.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 9BE2420146; Wed, 4 Jan 2023 12:56:50 +0100 (CET) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pD2O3-009SqS-0B; Wed, 04 Jan 2023 12:56:51 +0100 Date: Wed, 4 Jan 2023 12:56:50 +0100 From: Samuel Thibault To: wangshuo_1994@foxmail.com Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] hurd fcntl: remove duplicate do...while in LOCKED macro Message-ID: <20230104115650.7rqlrdmxb25jpik2@begin> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: wangshuo_1994@foxmail.com, le mer. 04 janv. 2023 18:30:57 +0800, a ecrit: > From: abushwang > > 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. That's true, but that's a bit hidden, and might someday go away. The original purpose of my change was to avoid exposing a double ';' to static analyzers who then frown upon it. The do { } while(0) shouldn't be harmful anyway, so I prefer to keep it. Samuel > Signed-off-by: abushwang > --- > 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