[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070328131454.cdb06bc3.akpm@linux-foundation.org>
Date: Wed, 28 Mar 2007 13:14:54 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Jiri Kosina <jikos@...os.cz>
Cc: Lee Revell <rlrevell@...-job.com>,
Toralf Förster <toralf.foerster@....de>,
andrea@...e.de, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org
Subject: Re: fs/block_dev.c:953: warning: 'found' might be used
uninitialized in this function
On Wed, 28 Mar 2007 19:23:32 +0200 (CEST)
Jiri Kosina <jikos@...os.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@...e.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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists