DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
Subsystems (2)
PATCH 1/1 DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
drivers/md/dm-raid.c: In function 'raid_ctr':drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized] drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared here
It appears unlikely that rebuilds_per_group could be used before set, but set it to 0 anyways just to shutup GCC.
--- drivers/md/dm-raid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-raid.c +1 -1
@@ -380,7 +380,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)static int validate_raid_redundancy (struct raid_set *rs) {unsigned i, rebuild_cnt =0 ; -unsigned rebuilds_per_group, copies, d; +unsigned rebuilds_per_group =0 , copies, d;unsigned group_size, last_group_start;for (i =0 ; i < rs->md.raid_disks; i++)
Signature · 1 line
1.7.9.5
Dear Tim,
thanks for the patch.
Am Mittwoch, den 20.02.2013, 13:31 -0700 schrieb Tim Gardner:
Noting the gcc version and build environment is never wrong. ;-)
Quoted 5 lines
drivers/md/dm-raid.c: In function 'raid_ctr':drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared hereIt appears unlikely that
rebuilds_per_groupcould be used before set,
Why? Otherwise the compiler would not complain, right?
Quoted 1 line
but set it to 0 anyways just to shutup GCC.
Unfortunately I do not know what linux-next version you tested, so the line numbers are off in.
$ git describe
v3.7.5-4-g9c2ab66Quoted 14 lines
Cc Alasdair Kergon <[email protected]>Cc Neil Brown <[email protected]>Signed-off-by Tim Gardner <[email protected]>--- drivers/md/dm-raid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-raid.c +0
-0
drivers/md/dm-raid.c static int validate_region_size(struct raid_set *rs, unsigned long region_size) · line 386
Quoted 8 lines
drivers/md/dm-raid.c +1
-1@@ -380,7 +380,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)static int validate_raid_redundancy (struct raid_set *rs) {unsigned i, rebuild_cnt =0 ; -unsigned rebuilds_per_group, copies, d; +unsigned rebuilds_per_group =0 , copies, d;unsigned group_size, last_group_start;for (i =0 ; i < rs->md.raid_disks; i++)
Thanks,
Paul
Dear Tim,
Am Mittwoch, den 20.02.2013, 23:16 +0100 schrieb Paul Menzel:
Quoted 12 lines
Am Mittwoch, den 20.02.2013, 13:31 -0700 schrieb Tim Gardner:
Noting the
gccversion and build environment is never wrong. ;-)Quoted 5 lines
drivers/md/dm-raid.c: In function 'raid_ctr':drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared hereIt appears unlikely that
rebuilds_per_groupcould be used before set,Why? Otherwise the compiler would not complain, right?
Quoted 7 lines
Quoted 1 line
but set it to 0 anyways just to shutup GCC.
Unfortunately I do not know what linux-next version you tested, so the line numbers are off in.
$ git describe v3.7.5-4-g9c2ab66
See below …
Quoted 11 lines
drivers/md/dm-raid.c
Quoted 11 lines
Cc Alasdair Kergon <[email protected]>Cc Neil Brown <[email protected]>Signed-off-by Tim Gardner <[email protected]>--- drivers/md/dm-raid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-raid.c +0
-0
Git to the rescue. I guess I should be able to find that commit to make sense of the line numbers.
Quoted 11 lines
drivers/md/dm-raid.c static int validate_region_size(struct raid_set *rs, unsigned long region_size) · line 386
Quoted 11 lines
drivers/md/dm-raid.c +1
-1@@ -380,7 +380,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)static int validate_raid_redundancy (struct raid_set *rs) {unsigned i, rebuild_cnt =0 ; -unsigned rebuilds_per_group, copies, d; +unsigned rebuilds_per_group =0 , copies, d;unsigned group_size, last_group_start;for (i =0 ; i < rs->md.raid_disks; i++)
Thanks,
Paul
Quoted 10 lines · On Wed, 20 Feb 2013 23:16:37 +0100 Paul Menzel <[email protected]> wrote:
Dear Tim,
thanks for the patch.
Am Mittwoch, den 20.02.2013, 13:31 -0700 schrieb Tim Gardner:
Noting the
gccversion and build environment is never wrong. ;-)
Quoted 7 lines
Quoted 5 lines
drivers/md/dm-raid.c: In function 'raid_ctr':drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared hereIt appears unlikely that
rebuilds_per_groupcould be used before set,Why? Otherwise the compiler would not complain, right?
It is not simply unlikely, it is impossible. But gcc isn't that clever yet.
Quoted 8 lines
drivers/md/dm-raid.c static int validate_region_size(struct raid_set *rs, unsigned long region_size) · line 383
Quoted 8 lines
drivers/md/dm-raid.c +1
-1@@ -380,7 +380,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)static int validate_raid_redundancy (struct raid_set *rs) {unsigned i, rebuild_cnt =0 ; -unsigned rebuilds_per_group, copies, d; +unsigned rebuilds_per_group =0 , copies, d;
This should either be:
unsigned uninitialized_var(rebuilds_per_group);
unsigned copies, d;which the old way and is being deprecated, but at least is consistent with the kernel as it is, or
unsigned rebuilds_per_group = 0 /* GCC */; unsigned copies,d;
which is apparently the new way which I believe is due to be imposed on the kernel immediately after 3.9-rc1
https://lwn.net/Articles/529954/
NeilBrown
Alasdair G Kergon
maintainerQuoted 6 lines · Tim Gardner
drivers/md/dm-raid.c: In function 'raid_ctr':drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared hereIt appears unlikely that
rebuilds_per_groupcould be used before set, but set it to 0 anyways just to shutup GCC.
Looks bogus to me.uninitialized_var() please.
Alasdair
PATCH v2 1/1 DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized] drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared here
It is impossible that rebuilds_per_group could be used before set, but set it to 0 anyways to silence GCC warnings.
---
v2 - Added GCC comment. Update commit log with a more definite explanation.
As Neil has pointed out, https://lwn.net/Articles/529954/ indicates uninitialized_var() is going away.
drivers/md/dm-raid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/dm-raid.c +2 -1
@@ -380,7 +380,8 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)static int validate_raid_redundancy (struct raid_set *rs) {unsigned i, rebuild_cnt =0 ; -unsigned rebuilds_per_group, copies, d; +unsigned rebuilds_per_group =0 ;/* GCC 4.6.3 */ +unsigned copies, d;unsigned group_size, last_group_start;for (i =0 ; i < rs->md.raid_disks; i++)
Signature · 1 line
1.7.9.5
2013/2/21 Tim Gardner <[email protected]>:
Quoted 2 lines
drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared here
Hello, is this patch getting merged? I'm also seeing this exact same compiler warning in my mainline builds.
Tommi
Quoted 41 lines
It is impossible that
rebuilds_per_groupcould be used before set, but set it to 0 anyways to silence GCC warnings.Cc Alasdair Kergon <[email protected]>Cc Neil Brown <[email protected]>Signed-off-by Tim Gardner <[email protected]>---
v2 - Added GCC comment. Update commit log with a more definite explanation.
As Neil has pointed out, https://lwn.net/Articles/529954/ indicates
uninitialized_var()is going away.drivers/md/dm-raid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/md/dm-raid.c +2
-2@@ -380,7 +380,8 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)static int validate_raid_redundancy (struct raid_set *rs) {unsigned i, rebuild_cnt =0 ; -unsigned rebuilds_per_group, copies, d; +unsigned rebuilds_per_group =0 ;/* GCC 4.6.3 */ +unsigned copies, d;unsigned group_size, last_group_start;for (i =0 ; i < rs->md.raid_disks; i++) --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 9 lines · Tommi Rantala
2013/2/21 Tim Gardner <[email protected]>:
Quoted 2 lines
drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared hereHello, is this patch getting merged? I'm also seeing this exact same compiler warning in my mainline builds.
Tommi
Dunno. I haven't hassled anyone because it _is_ just a warning.
Signature · 1 line
Tim Gardner [email protected]