public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Andreas Schwab <schwab@suse.de>, libc-alpha@sourceware.org
Subject: Re: [PATCH] socket: Use offsetof in SUN_LEN (bug 29578)
Date: Thu, 6 Oct 2022 14:36:47 -0300	[thread overview]
Message-ID: <448cd2ac-9db8-4932-2e6c-e781a7184dc0@linaro.org> (raw)
In-Reply-To: <mvmh713qy9m.fsf@suse.de>



On 19/09/22 10:39, Andreas Schwab via Libc-alpha wrote:
> Use offsetof instead of its traditional expansion in the definition of the
> SUN_LEN macro, to avoid a warning from the undefined behaviour sanitizer.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  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 <stddef.h>
>  # include <string.h>		/* 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
>  

      reply	other threads:[~2022-10-06 17:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 13:39 Andreas Schwab
2022-10-06 17:36 ` Adhemerval Zanella Netto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=448cd2ac-9db8-4932-2e6c-e781a7184dc0@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).