From patchwork Mon Jan 2 10:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 62534 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDFB7382FAD8 for ; Mon, 2 Jan 2023 10:10:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id C93513858C60 for ; Mon, 2 Jan 2023 10:09:44 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 2057F2014F; Mon, 2 Jan 2023 11:09:42 +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 qeOuEK6wg8D2; Mon, 2 Jan 2023 11:09:41 +0100 (CET) Received: from begin (lfbn-bor-1-376-208.w109-215.abo.wanadoo.fr [109.215.91.208]) (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 0DF3220152; Mon, 2 Jan 2023 11:09:41 +0100 (CET) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pCHlD-00BemF-2x; Mon, 02 Jan 2023 11:09:39 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 6/7] hurd fcntl: Make LOCKED macro more robust Date: Mon, 2 Jan 2023 11:09:37 +0100 Message-Id: <20230102100938.2778311-7-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230102100938.2778311-1-samuel.thibault@ens-lyon.org> References: <20230102100938.2778311-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- sysdeps/mach/hurd/fcntl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c index ea35e9b977..48608493a1 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) \ +#define LOCKED(expr) do { \ HURD_CRITICAL_BEGIN; \ __spin_lock (&d->port.lock); \ if (d->port.port == MACH_PORT_NULL) \ @@ -117,7 +117,8 @@ __libc_fcntl (int fd, int cmd, ...) else \ result = (expr); \ __spin_unlock (&d->port.lock); \ - HURD_CRITICAL_END; + HURD_CRITICAL_END; \ +} while(0) case F_GETFD: /* Get descriptor flags. */ LOCKED (d->flags);