Re: fs/block_dev.c:953: warning: 'found' might be used uninitializedin this function
From: Jiri Kosina
Date: Wed Mar 28 2007 - 13:24:01 EST
On Wed, 28 Mar 2007, Lee Revell wrote:
> > I compiled current git source 2.6.21-rc5-g28defbe and got 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
> > ...
> Most of these warnings are really GCC bugs. Please examine the code
> in question.
Anyway imho this time gcc got it right?
From: Jiri Kosina <jkosina@xxxxxxx>
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@xxxxxxx>
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;
if (!kobj)
return -EINVAL;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/