From patchwork Wed Jan 1 21:12:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 103851 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 5F3C33857C5D for ; Wed, 1 Jan 2025 21:13:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F3C33857C5D X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 230053858431 for ; Wed, 1 Jan 2025 21:12:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 230053858431 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 230053858431 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735765961; cv=none; b=Wm0E+lmmMWz7KrF7YYRTN6EBRqlyWhnPI1d6WRPFxf0U0RFAdIpdN8fgH+8IK1ocM4192Uk47fOPPluqgRYwXWmW3umliWipD9GUBJ7vvrwHAFSGIBh+bEmhhymGtmsdgeobZMD9oPeK07X0oKkw1hDGOa33dVXUJQ8gUYYHPcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735765961; c=relaxed/simple; bh=7K9b6+xiCTS21SQW1lf0AMHcc8da9c5G1dbk6/NYWps=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XpKOWGgGTDef1JqCzDhDI+BcckwSLk/3i3wUp3bsrZA3GHU5uNHAD2OUtK6hzApbXRCCklbF3cq2qEAFRpqV89pUoUCIFf4yPkDZQDMANnbrJbvPJtrhh1pk5UzwogAPqv+1TkPKYMZmqnVBSpx7Bk6xb0MLwvygIhk6h0WQX8g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 230053858431 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 6A56EA49B7; Wed, 1 Jan 2025 22:12:39 +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 XHwMtmae09U6; Wed, 1 Jan 2025 22:12:39 +0100 (CET) Received: from begin.home (aaubervilliers-652-1-289-58.w82-121.abo.wanadoo.fr [82.121.86.58]) (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 50286A49B5; Wed, 1 Jan 2025 22:12:39 +0100 (CET) Received: from samy by begin.home with local (Exim 4.98) (envelope-from ) id 1tT618-00000006Zcn-3WiA; Wed, 01 Jan 2025 22:12:38 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org, Diego Nieto Cid Subject: [hurd,commited] bits/socket.h: Update to recent BSD definition Date: Wed, 1 Jan 2025 22:12:35 +0100 Message-ID: <20250101211235.1566900-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, 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.30 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 The old BSD 4.4 definition (not used by Linux) was not 64b-proof: the cmsg_data field is supposed to CMSG_ALIGN'ed (as can be also seen in the CMSG_LEN macro). Suggested-by: Diego Nieto Cid --- bits/socket.h | 12 ++++-------- sysdeps/mach/hurd/bits/socket.h | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/bits/socket.h b/bits/socket.h index 62276fb49d..e83ad5bc01 100644 --- a/bits/socket.h +++ b/bits/socket.h @@ -221,17 +221,13 @@ struct cmsghdr of cmsghdr structure. */ int cmsg_level; /* Originating protocol. */ int cmsg_type; /* Protocol specific type. */ -#if __glibc_c99_flexarr_available - __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */ -#endif + /* This field is to be aligned with CMSG_ALIGN */ + /* __extension__ unsigned char __cmsg_data __flexarr; */ /* Ancillary data. */ }; /* Ancillary data object manipulation macros. */ -#if __glibc_c99_flexarr_available -# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data) -#else -# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1)) -#endif +#define CMSG_DATA(cmsg) \ + ((unsigned char *) (cmsg) + CMSG_ALIGN (sizeof (struct cmsghdr))) #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg) diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h index 01af80231a..8c18cef579 100644 --- a/sysdeps/mach/hurd/bits/socket.h +++ b/sysdeps/mach/hurd/bits/socket.h @@ -228,17 +228,13 @@ struct cmsghdr of cmsghdr structure. */ int cmsg_level; /* Originating protocol. */ int cmsg_type; /* Protocol specific type. */ -#if __glibc_c99_flexarr_available - __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */ -#endif + /* This field is to be aligned with CMSG_ALIGN */ + /* __extension__ unsigned char __cmsg_data __flexarr; */ /* Ancillary data. */ }; /* Ancillary data object manipulation macros. */ -#if __glibc_c99_flexarr_available -# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data) -#else -# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1)) -#endif +#define CMSG_DATA(cmsg) \ + ((unsigned char *) (cmsg) + CMSG_ALIGN (sizeof (struct cmsghdr))) #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)