public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Michal Marek <mmarek@suse.cz>
Cc: Peter Teoh <htmldeveloper@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scripts/kconfig/menu.c warning for uninitialized "jump"
Date: Fri, 28 Nov 2014 10:50:12 -0800	[thread overview]
Message-ID: <1417200612.4305.7.camel@perches.com> (raw)
In-Reply-To: <547879BE.4050502@suse.cz>

On Fri, 2014-11-28 at 14:33 +0100, Michal Marek wrote:
> On 2014-11-21 05:22, Peter Teoh wrote:
> > This warning was found in v3.18-rc3-68-g20f3963 of Linus git-tree.
> > 
> >   SHIPPED scripts/kconfig/zconf.hash.c
> >   HOSTCC  scripts/kconfig/zconf.tab.o
> > In file included from scripts/kconfig/zconf.tab.c:2537:0:
> > scripts/kconfig/menu.c: In function ‘get_symbol_str’:
> > scripts/kconfig/menu.c:590:18: warning: ‘jump’ may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >      jump->offset = strlen(r->s);
> >                   ^
> > scripts/kconfig/menu.c:551:19: note: ‘jump’ was declared here
> >   struct jump_key *jump;
> >                    ^
> 
> First of all, the warning is bogus (the condition under which 'jump' is
> used is stronger than that under which 'jump' is initialized). But since
> people have been reporting the warning on and off for some time, we have
> to shut it up somehow, as the affected gcc versions are not dying out,
> apparently.
> 
> 
> > -                       if (head && location && menu == location)
> > +                       if (head && location && (menu == location) && (jump))
> >                                 jump->offset = strlen(r->s);
> 
> Let's assume, for the sake of argument, that gcc is right and jump may
> be uninitialized here. Then the added check for jump being non-null just
> tests an uninitialized variable and thus behaves randomly. It prevents
> the code from writing to NULL->offset, but does not prevent it from
> writing to <random address>->offset.

Maybe the 'right' thing to do is to mark the xmalloc
prototype as "__attribute__((returns_nonnull))"



  reply	other threads:[~2014-11-28 18:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21  4:22 [PATCH] scripts/kconfig/menu.c warning for uninitialized "jump" Peter Teoh
2014-11-28 13:33 ` Michal Marek
2014-11-28 18:50   ` Joe Perches [this message]
2014-11-28 21:39     ` Michal Marek

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=1417200612.4305.7.camel@perches.com \
    --to=joe@perches.com \
    --cc=htmldeveloper@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    /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