[dm-devel] [PATCH] dm-raid: suppress uninitialized variable warning

Mikulas Patocka mpatocka at redhat.com
Thu Mar 21 21:32:17 UTC 2013


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.

Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
Cc: stable at kernel.org

---
 drivers/md/dm-raid.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-3.9-rc3-fast/drivers/md/dm-raid.c
===================================================================
--- linux-3.9-rc3-fast.orig/drivers/md/dm-raid.c	2013-03-21 22:16:42.000000000 +0100
+++ linux-3.9-rc3-fast/drivers/md/dm-raid.c	2013-03-21 22:17:05.000000000 +0100
@@ -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++)




More information about the dm-devel mailing list