netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Julian Anastasov <ja@ssi.bg>
Cc: Wensong Zhang <wensong@linux-vs.org>,
	Simon Horman <horms@verge.net.au>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Patrick McHardy <kaber@trash.net>,
	Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
	"David S. Miller" <davem@davemloft.net>,
	Quentin Armitage <quentin@armitage.org.uk>,
	netdev@vger.kernel.org, lvs-devel@vger.kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netfilter: ip_vs_sync: fix bogus maybe-uninitialized warning
Date: Mon, 24 Oct 2016 22:21:59 +0200	[thread overview]
Message-ID: <12460209.DFK3VxnryE@wuerfel> (raw)
In-Reply-To: <alpine.LFD.2.11.1610242226310.2276@ja.home.ssi.bg>

On Monday, October 24, 2016 10:47:54 PM CEST Julian Anastasov wrote:
> > diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> > index 1b07578bedf3..9350530c16c1 100644
> > --- a/net/netfilter/ipvs/ip_vs_sync.c
> > +++ b/net/netfilter/ipvs/ip_vs_sync.c
> > @@ -283,6 +283,7 @@ struct ip_vs_sync_buff {
> >   */
> >  static void ntoh_seq(struct ip_vs_seq *no, struct ip_vs_seq *ho)
> >  {
> > +     memset(ho, 0, sizeof(*ho));
> >       ho->init_seq       = get_unaligned_be32(&no->init_seq);
> >       ho->delta          = get_unaligned_be32(&no->delta);
> >       ho->previous_delta = get_unaligned_be32(&no->previous_delta);
> 
>         So, now there is a double write here?

Correct. I would hope that a sane version of gcc would just not
perform the first write. What happens instead is that the version
that produces the warning here moves the initialization to the
top of the calling function.

>         What about such constructs?:
> 
>         *ho = (struct ip_vs_seq) {
>                 .init_seq       = get_unaligned_be32(&no->init_seq),
>                 ...
>         };
> 
>         Any difference in the compiled code or warnings?

Yes, it's one of many things I tried. What happens here is that
the warning remains as long as all fields are initialized together,
e.g. these two produces the same warning:

a)
    ho->init_seq       = get_unaligned_be32(&no->init_seq);
    ho->delta          = get_unaligned_be32(&no->delta);
    ho->previous_delta = get_unaligned_be32(&no->previous_delta);

b)
   *ho = (struct ip_vs_seq) {
       .init_seq       = get_unaligned_be32(&no->init_seq);
       .delta          = get_unaligned_be32(&no->delta);
       .previous_delta = get_unaligned_be32(&no->previous_delta);
   };

but this one does not:

c)
   *ho = (struct ip_vs_seq) {
       .delta          = get_unaligned_be32(&no->delta);
       .previous_delta = get_unaligned_be32(&no->previous_delta);
   };
   ho->init_seq       = get_unaligned_be32(&no->init_seq);

I have absolutely no idea what is going on inside of gcc here.

	Arnd

  reply	other threads:[~2016-10-24 20:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 15:34 [PATCH] netfilter: ip_vs_sync: fix bogus maybe-uninitialized warning Arnd Bergmann
2016-10-24 19:47 ` Julian Anastasov
2016-10-24 20:21   ` Arnd Bergmann [this message]
2016-10-25 16:15     ` David Laight
2016-10-28  9:34   ` Pablo Neira Ayuso
2016-10-28 11:40     ` Simon Horman
2016-10-28 12:16       ` Pablo Neira Ayuso

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=12460209.DFK3VxnryE@wuerfel \
    --to=arnd@arndb.de \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=kaber@trash.net \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=quentin@armitage.org.uk \
    --cc=wensong@linux-vs.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 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 NNTP newsgroup(s).