lkml.org 
[lkml]   [2007]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: fs/block_dev.c:953: warning: 'found' might be used uninitialized in this function
Date
On Mar 28, 2007, at 16:14:54, Andrew Morton wrote:
> 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.
>
> 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 */

Well, that would be correct except the warning is an actual kernel
bug. Read Jiri's message (which you also quoted):
> 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.

So in this case it has to be initialized to NULL or there's a
potential BUG() lurking.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-03-30 05:19    [from the cache]
©2003-2011 Jasper Spaans