Gcc warns that "ret" can be used uninitialized. It can''t actually be used uninitialized because btrfs_num_copies() always returns 1 or more. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 064b29b..c053e90 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup( static int btrfsic_process_superblock(struct btrfsic_state *state, struct btrfs_fs_devices *fs_devices) { - int ret; + int ret = 0; struct btrfs_super_block *selected_super; struct list_head *dev_head = &fs_devices->devices; struct btrfs_device *device; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Feb 22, 2012 at 10:30:55AM +0300, Dan Carpenter wrote:>Gcc warns that "ret" can be used uninitialized. It can''t actually be >used uninitialized because btrfs_num_copies() always returns 1 or more. > >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > >diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c >index 064b29b..c053e90 100644 >--- a/fs/btrfs/check-integrity.c >+++ b/fs/btrfs/check-integrity.c >@@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup( > static int btrfsic_process_superblock(struct btrfsic_state *state, > struct btrfs_fs_devices *fs_devices) > { >- int ret; >+ int ret = 0;Does int uninitialized_var(ret); work? The assignment to zero actually generates additional (unnecessary) code. David -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Feb 22, 2012 at 08:29:26AM -0800, David Brown wrote:> On Wed, Feb 22, 2012 at 10:30:55AM +0300, Dan Carpenter wrote: > >Gcc warns that "ret" can be used uninitialized. It can''t actually be > >used uninitialized because btrfs_num_copies() always returns 1 or more. > > > >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > > >diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c > >index 064b29b..c053e90 100644 > >--- a/fs/btrfs/check-integrity.c > >+++ b/fs/btrfs/check-integrity.c > >@@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup( > >static int btrfsic_process_superblock(struct btrfsic_state *state, > > struct btrfs_fs_devices *fs_devices) > >{ > >- int ret; > >+ int ret = 0; > > Does > > int uninitialized_var(ret); > > work? The assignment to zero actually generates additional > (unnecessary) code.Sure. I can resend it. regards, dan carpenter
Gcc warns that "ret" can be used uninitialized. It can''t actually be used uninitialized because btrfs_num_copies() always returns 1 or more. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- v2: use the uninitialized_var() macro instead of initializing to 0. diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 064b29b..3bb3853 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup( static int btrfsic_process_superblock(struct btrfsic_state *state, struct btrfs_fs_devices *fs_devices) { - int ret; + int uninitialized_var(ret); struct btrfs_super_block *selected_super; struct list_head *dev_head = &fs_devices->devices; struct btrfs_device *device;