LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] - fix compile warning: `found' might be used uninitialized in this function
@ 2007-03-21 23:48 roland
2007-03-21 23:56 ` Johannes Weiner
0 siblings, 1 reply; 5+ messages in thread
From: roland @ 2007-03-21 23:48 UTC (permalink / raw)
To: linux-kernel
Hello !
the attached patch should fix the following compile 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
i`m an absolutely awful programmer , but feel free to comment, ignore or
.... merge.
regards
Roland Kletzing
--- linux-2.6.20.3/fs/block_dev.c.orig 2007-03-22 00:07:49.270353920 +0100
+++ linux-2.6.20.3/fs/block_dev.c 2007-03-22 00:07:33.875694264 +0100
@@ -950,7 +950,7 @@
struct kobject *kobj)
{
int res;
- struct bd_holder *bo, *found;
+ struct bd_holder *bo, *found = NULL;
if (!kobj)
return -EINVAL;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] - fix compile warning: `found' might be used uninitialized in this function
2007-03-21 23:48 [PATCH] - fix compile warning: `found' might be used uninitialized in this function roland
@ 2007-03-21 23:56 ` Johannes Weiner
2007-03-22 8:45 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2007-03-21 23:56 UTC (permalink / raw)
To: roland; +Cc: linux-kernel
Hi,
On Thu, Mar 22, 2007 at 12:48:05AM +0100, roland wrote:
> fs/block_dev.c: In function `bd_claim_by_kobject':
> fs/block_dev.c:953: warning: `found' might be used uninitialized in this
> function
found actually _is_ used uninitialized if the call to bd_claim() returns
anything but 0. Thank you!
=Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] - fix compile warning: `found' might be used uninitialized in this function
2007-03-21 23:56 ` Johannes Weiner
@ 2007-03-22 8:45 ` Andrew Morton
2007-03-22 16:26 ` Johannes Weiner
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2007-03-22 8:45 UTC (permalink / raw)
To: Johannes Weiner; +Cc: roland, linux-kernel
On Thu, 22 Mar 2007 00:56:08 +0100 Johannes Weiner <hannes-kernel@saeurebad.de> wrote:
> On Thu, Mar 22, 2007 at 12:48:05AM +0100, roland wrote:
> > fs/block_dev.c: In function `bd_claim_by_kobject':
> > fs/block_dev.c:953: warning: `found' might be used uninitialized in this
> > function
>
> found actually _is_ used uninitialized if the call to bd_claim() returns
> anything but 0.
No, it isn't.
if (res || found)
free_bd_holder(bo);
`found' won't be evaluated if res!=0.
The code in there is irksome - it'd be nice to find some way of
restructuring it to make it less obscure, and to kill that warning.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] - fix compile warning: `found' might be used uninitialized in this function
2007-03-22 8:45 ` Andrew Morton
@ 2007-03-22 16:26 ` Johannes Weiner
2007-03-22 17:16 ` Johannes Weiner
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2007-03-22 16:26 UTC (permalink / raw)
To: Andrew Morton; +Cc: roland, linux-kernel
Hi,
On Thu, Mar 22, 2007 at 12:45:40AM -0800, Andrew Morton wrote:
> > On Thu, Mar 22, 2007 at 12:48:05AM +0100, roland wrote:
> > > fs/block_dev.c: In function `bd_claim_by_kobject':
> > > fs/block_dev.c:953: warning: `found' might be used uninitialized in this
> > > function
> >
> > found actually _is_ used uninitialized if the call to bd_claim() returns
> > anything but 0.
>
> No, it isn't.
>
> if (res || found)
> free_bd_holder(bo);
>
> `found' won't be evaluated if res!=0.
Oh, thank you very much. So this warning is another gcc false-positive?
> The code in there is irksome - it'd be nice to find some way of
> restructuring it to make it less obscure, and to kill that warning.
Functionscope or filescope? ;)
=Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] - fix compile warning: `found' might be used uninitialized in this function
2007-03-22 16:26 ` Johannes Weiner
@ 2007-03-22 17:16 ` Johannes Weiner
0 siblings, 0 replies; 5+ messages in thread
From: Johannes Weiner @ 2007-03-22 17:16 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Hi,
On Thu, Mar 22, 2007 at 05:26:04PM +0100, Johannes Weiner wrote:
> > The code in there is irksome - it'd be nice to find some way of
> > restructuring it to make it less obscure, and to kill that warning.
>
> Functionscope or filescope? ;)
Oh well... I think the latter. I wil clean it up and send the patches
in several steps to seperate opticals from functionals.
=Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-03-22 17:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21 23:48 [PATCH] - fix compile warning: `found' might be used uninitialized in this function roland
2007-03-21 23:56 ` Johannes Weiner
2007-03-22 8:45 ` Andrew Morton
2007-03-22 16:26 ` Johannes Weiner
2007-03-22 17:16 ` Johannes Weiner
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).