All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <netdev@vger.kernel.org>
Subject: Re: [PATCH iproute2] ila: fix array overflow warning
Date: Thu, 5 Oct 2023 12:16:22 +0200	[thread overview]
Message-ID: <87jzs1qko5.fsf@nvidia.com> (raw)
In-Reply-To: <20231004170258.25575-1-stephen@networkplumber.org>


Stephen Hemminger <stephen@networkplumber.org> writes:

> Aliasing a 64 bit value seems to confuse Gcc 12.2.
> ipila.c:57:32: warning: ‘addr’ may be used uninitialized [-Wmaybe-uninitialized]
>
> Use a union instead.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Reviewed-by: Petr Machata <petrm@nvidia.com>

> ---
>  ip/ipila.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/ip/ipila.c b/ip/ipila.c
> index 23b19a108862..f4387e039f97 100644
> --- a/ip/ipila.c
> +++ b/ip/ipila.c
> @@ -47,14 +47,17 @@ static int genl_family = -1;
>  
>  static void print_addr64(__u64 addr, char *buff, size_t len)
>  {
> -	__u16 *words = (__u16 *)&addr;
> +	union {
> +		__u64 id64;
> +		__u16 words[4];
> +	} id = { .id64 = addr };
>  	__u16 v;
>  	int i, ret;
>  	size_t written = 0;
>  	char *sep = ":";
>  
>  	for (i = 0; i < 4; i++) {
> -		v = ntohs(words[i]);
> +		v = ntohs(id.words[i]);
>  
>  		if (i == 3)
>  			sep = "";


  reply	other threads:[~2023-10-05 13:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 17:02 [PATCH iproute2] ila: fix array overflow warning Stephen Hemminger
2023-10-05 10:16 ` Petr Machata [this message]
2023-10-05 17:10 ` patchwork-bot+netdevbpf

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=87jzs1qko5.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.