From: David Miller <davem@davemloft.net>
To: arnd@arndb.de
Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, fw@strlen.de,
dsahern@gmail.com, kafai@fb.com, weiwan@google.com,
xiyou.wangcong@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning
Date: Fri, 18 Aug 2017 10:49:40 -0700 (PDT) [thread overview]
Message-ID: <20170818.104940.305624900632112023.davem@davemloft.net> (raw)
In-Reply-To: <20170818113434.3037484-1-arnd@arndb.de>
From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 18 Aug 2017 13:34:22 +0200
> Adding a lock around one of the assignments prevents gcc from
> tracking the state of the local 'fibmatch' variable, so it can no
> longer prove that 'dst' is always initialized, leading to a bogus
> warning:
>
> net/ipv6/route.c: In function 'inet6_rtm_getroute':
> net/ipv6/route.c:3659:2: error: 'dst' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This moves the other assignment into the same lock to shut up the
> warning.
>
> Fixes: 121622dba8da ("ipv6: route: make rtm_getroute not assume rtnl is locked")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> net/ipv6/route.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> This kind of warning involving an unlock between variable initialization
> and use is relatively frequent for false-positives. I should try to
> seek clarification from the gcc developers on whether this can be
> improved.
This will have to do for now I suppose.
I guess the issue is that if the local variable ever sits on the stack
then the memory barriers in the locks block the full dataflow
analysis.
But this makes no sense from a dataflow perspective. Even if the
local variable has a stack slot, there is no "escapability" of that
memory addres to foreign modifications.
If I had a nickel for every uninitialized variable warning we had to
work around....
next prev parent reply other threads:[~2017-08-18 17:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 11:34 [net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning Arnd Bergmann
2017-08-18 17:49 ` David Miller [this message]
2017-08-18 19:46 ` Arnd Bergmann
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=20170818.104940.305624900632112023.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=arnd@arndb.de \
--cc=dsahern@gmail.com \
--cc=fw@strlen.de \
--cc=kafai@fb.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=weiwan@google.com \
--cc=xiyou.wangcong@gmail.com \
--cc=yoshfuji@linux-ipv6.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).