From: Andrew Morton <akpm@linux-foundation.org>
To: Jiri Kosina <jikos@jikos.cz>
Cc: "Lee Revell" <rlrevell@joe-job.com>,
"Toralf Förster" <toralf.foerster@gmx.de>,
andrea@suse.de, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: fs/block_dev.c:953: warning: 'found' might be used uninitialized in this function
Date: Wed, 28 Mar 2007 13:14:54 -0700 [thread overview]
Message-ID: <20070328131454.cdb06bc3.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0703281909240.29565@twin.jikos.cz>
On Wed, 28 Mar 2007 19:23:32 +0200 (CEST)
Jiri Kosina <jikos@jikos.cz> wrote:
> blockdev: bd_claim_by_kobject() could check value of unititalized pointer
>
> Fixes this warning:
>
> fs/block_dev.c: In function `bd_claim_by_kobject':
> fs/block_dev.c:953: warning: 'found' might be used uninitialized in this function
>
> struct bd_holder *found is initialized only when bd_claim() returns zero. If it
> returns nonzero, ptr stays uninitialized. Later the value of the pointer is checked.
>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
>
> diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 575076c..e87d84a 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -950,7 +950,7 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
> struct kobject *kobj)
> {
> int res;
> - struct bd_holder *bo, *found;
> + struct bd_holder *bo, *found = NULL;
that generates extra code and people get upset.
One approach which we could ue in here is
struct bd_holder *found = found; /* Suppress bogus gcc warning */
which (surprisingly) gcc will currently accept, and which shouldn't
generate more code, although I haven't verified this.
But it's all rather ad-hoc and unpleasant. I tend to think that we should
come up with some standardised way of squashing this warning - something
which stands out when one is reading the code, like
struct bd_holder *found;
squash_bogus_uninit_warning(found); /* useful comment goes here */
which is also unpleasant, but not as unpleasant as a screenful of warnings
which hide real problems, IMO.
next prev parent reply other threads:[~2007-03-28 20:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-28 16:47 fs/block_dev.c:953: warning: 'found' might be used uninitialized in this function Toralf Förster
2007-03-28 16:56 ` Lee Revell
2007-03-28 17:23 ` Jiri Kosina
2007-03-28 20:14 ` Andrew Morton [this message]
2007-03-28 21:59 ` Dan Aloni
2007-03-30 3:16 ` Kyle Moffett
2007-03-30 19:47 ` Adrian Bunk
2007-03-31 3:09 ` Cong WANG
2007-03-31 8:11 ` Toralf Förster
2007-03-31 14:04 ` Adrian Bunk
2007-03-30 19:40 ` Adrian Bunk
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=20070328131454.cdb06bc3.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andrea@suse.de \
--cc=jikos@jikos.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=rlrevell@joe-job.com \
--cc=toralf.foerster@gmx.de \
--cc=viro@zeniv.linux.org.uk \
/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.