Linux block layer
 help / color / mirror / Atom feed
* [PATCH] block: zoned: fix harmless maybe-uninitialized warning
@ 2016-10-21 15:42 Arnd Bergmann
  2016-10-21 20:46 ` Shaun Tancheff
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-10-21 15:42 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Arnd Bergmann, Shaun Tancheff, Martin K. Petersen, Damien Le Moal,
	Hannes Reinecke, linux-block, linux-kernel

The blkdev_report_zones produces a harmless warning when
-Wmaybe-uninitialized is set, after gcc gets a little confused
about the multiple 'goto' here:

block/blk-zoned.c: In function 'blkdev_report_zones':
block/blk-zoned.c:188:13: error: 'nz' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Moving the assignment to nr_zones makes this a little simpler
while also avoiding the warning reliably. I'm removing the
extraneous initialization of 'int ret' in the same patch, as
that is semi-related and could cause an uninitialized use of
that variable to not produce a warning.

Fixes: 6a0cb1bc106f ("block: Implement support for zoned block devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 block/blk-zoned.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 667f95d86695..472211fa183a 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -80,7 +80,7 @@ int blkdev_report_zones(struct block_device *bdev,
 	unsigned int i, n, nz;
 	unsigned int ofst;
 	void *addr;
-	int ret = 0;
+	int ret;
 
 	if (!q)
 		return -ENXIO;
@@ -179,14 +179,12 @@ int blkdev_report_zones(struct block_device *bdev,
 
 	}
 
+	*nr_zones = nz;
 out:
 	bio_for_each_segment_all(bv, bio, i)
 		__free_page(bv->bv_page);
 	bio_put(bio);
 
-	if (ret == 0)
-		*nr_zones = nz;
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(blkdev_report_zones);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-25  2:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-21 15:42 [PATCH] block: zoned: fix harmless maybe-uninitialized warning Arnd Bergmann
2016-10-21 20:46 ` Shaun Tancheff
2016-10-23 23:38 ` Damien Le Moal
2016-10-25  1:00 ` Martin K. Petersen
2016-10-25  2:51   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox