From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2138) id AB8CE385829E; Mon, 10 Oct 2022 07:32:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB8CE385829E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665387159; bh=54ygOKWOQiepfRifWVHYGR0edyTfhIJ+hm6MVNur3tw=; h=From:To:Subject:Date:From; b=rA2Khsxz7XVBFP7HqQFRfuJdQJpBc06H4IbA3fJAZmOJaE9R+ZweJZH2OuYlvFHL8 XZJm5QmMWsXLgQ2T9MftOqxDh8z1ZFXEeT0rrJNzbVW9cLcg0jzuF6hedxvV4vYS8D grr9M5Tbyiu3OWqfx6NZn1W8rjGjpyR40ZIE0WBI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Andreas Schwab To: glibc-cvs@sourceware.org Subject: [glibc] socket: Use offsetof in SUN_LEN (bug 29578) X-Act-Checkin: glibc X-Git-Author: Andreas Schwab X-Git-Refname: refs/heads/master X-Git-Oldrev: 954b8f38958de72c4712088735eb175118f17b51 X-Git-Newrev: c15318bfc5499d835c434a4d98b688aa2d928412 Message-Id: <20221010073239.AB8CE385829E@sourceware.org> Date: Mon, 10 Oct 2022 07:32:39 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c15318bfc5499d835c434a4d98b688aa2d928412 commit c15318bfc5499d835c434a4d98b688aa2d928412 Author: Andreas Schwab Date: Mon Sep 19 10:10:09 2022 +0200 socket: Use offsetof in SUN_LEN (bug 29578) Use offsetof instead of its traditional expansion in the definition of the SUN_LEN macro, to avoid a warning from the undefined behaviour sanitizer. Diff: --- 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