From patchwork Mon Sep 19 13:39:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 57747 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 B89073858425 for ; Mon, 19 Sep 2022 13:40:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B89073858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663594816; bh=lyQbq+Dgwapa9+Ztc8CJdMeaiM4AvukwsS4i2ComGH8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Nym1t+veofXJ7GEb0c5txLy8d1f8mMVp93kWAbcG6eFFIsxK62plViCljJyzawN5k jCvUdRMk8dH2nhp3JEYeO3WZWSMnLS/HIDCys35WoPEauT2PYnp3e5GIc9kDFx7bw1 0vm+n4yqRlTE9tZDgaoe9LCKG737xokYJJ1PPZww= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 21B733858418 for ; Mon, 19 Sep 2022 13:39:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21B733858418 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4F4E722169 for ; Mon, 19 Sep 2022 13:39:18 +0000 (UTC) Received: from hawking.suse.de (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id 484552C141 for ; Mon, 19 Sep 2022 13:39:18 +0000 (UTC) Received: by hawking.suse.de (Postfix, from userid 17005) id F35B844021C; Mon, 19 Sep 2022 15:39:17 +0200 (CEST) To: libc-alpha@sourceware.org Subject: [PATCH] socket: Use offsetof in SUN_LEN (bug 29578) X-Yow: Two with FLUFFO, hold th' BEETS..side of SOYETTES! Date: Mon, 19 Sep 2022 15:39:17 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, 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: , X-Patchwork-Original-From: Andreas Schwab via Libc-alpha From: Andreas Schwab Reply-To: Andreas Schwab Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Use offsetof instead of its traditional expansion in the definition of the SUN_LEN macro, to avoid a warning from the undefined behaviour sanitizer. Reviewed-by: Adhemerval Zanella --- socket/sys/un.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/socket/sys/un.h b/socket/sys/un.h index 454eafebc9..2b11300e28 100644 --- a/socket/sys/un.h +++ b/socket/sys/un.h @@ -34,10 +34,11 @@ struct sockaddr_un #ifdef __USE_MISC +# include # include /* For prototype of `strlen'. */ /* Evaluate to actual length of the `sockaddr_un' structure. */ -# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ +# define SUN_LEN(ptr) (offsetof (struct sockaddr_un, sun_path) \ + strlen ((ptr)->sun_path)) #endif