Skip to contentSkip to conversation

dm-raid: suppress uninitialized variable warning

PATCH New Mikulas Patocka 1 participant 1 message Mar 21, 2013 Device mapper

lore
Share & tools
lore

Mikulas Patocka

author maintainer
#0 lore raw

PATCH 1/1 dm-raid: suppress uninitialized variable warning

dm-raid: suppress uninitialized variable warning

This patch suppresses this warning:

drivers/md/dm-raid.c: In function 'raid_ctr':
drivers/md/dm-raid.c:427:54: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared here

The warning doesn't represent a real bug (rebuilds_per_group is always initialized in the first iteration of a loop), but gcc can't deduce it.

This patch should be backported to 3.8. It doesn't have to be backported to 3.7 and below because they don't have the problem with this varning.

---
 drivers/md/dm-raid.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-raid.c +1 -1
Index: linux-3.9-rc3-fast/drivers/md/dm-raid.c
===================================================================
@@ -380,7 +380,7 @@ static int validate_region_size(struct r
 static int validate_raid_redundancy(struct raid_set *rs)
 {
 	unsigned i, rebuild_cnt = 0;
-	unsigned rebuilds_per_group, copies, d;
+	unsigned uninitialized_var(rebuilds_per_group), copies, d;
 	unsigned group_size, last_group_start;
 
 	for (i = 0; i < rs->md.raid_disks; i++)