diff mbox series

scsi: sd_zbc: Fix compilation warning

Message ID 20190715053833.5973-1-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series scsi: sd_zbc: Fix compilation warning | expand

Commit Message

Damien Le Moal July 15, 2019, 5:38 a.m. UTC
kbuild test robot gets the following compilation warning using gcc 7.4
cross compilation for c6x (GCC_VERSION=7.4.0 make.cross ARCH=c6x).

   In file included from include/asm-generic/bug.h:18:0,
                    from arch/c6x/include/asm/bug.h:12,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from include/asm-generic/current.h:5,
                    from ./arch/c6x/include/generated/asm/current.h:1,
                    from include/linux/sched.h:12,
                    from include/linux/blkdev.h:5,
                    from drivers//scsi/sd_zbc.c:11:
   drivers//scsi/sd_zbc.c: In function 'sd_zbc_read_zones':
>> include/linux/kernel.h:62:48: warning: 'zone_blocks' may be used
   uninitialized in this function [-Wmaybe-uninitialized]
    #define __round_mask(x, y) ((__typeof__(x))((y)-1))
                                                   ^
   drivers//scsi/sd_zbc.c:464:6: note: 'zone_blocks' was declared here
     u32 zone_blocks;
         ^~~~~~~~~~~

Fix this by initializing the zone_blocks variable to 0.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/sd_zbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jens Axboe July 16, 2019, 2:05 p.m. UTC | #1
On 7/14/19 11:38 PM, Damien Le Moal wrote:
> kbuild test robot gets the following compilation warning using gcc 7.4
> cross compilation for c6x (GCC_VERSION=7.4.0 make.cross ARCH=c6x).
> 
>     In file included from include/asm-generic/bug.h:18:0,
>                      from arch/c6x/include/asm/bug.h:12,
>                      from include/linux/bug.h:5,
>                      from include/linux/thread_info.h:12,
>                      from include/asm-generic/current.h:5,
>                      from ./arch/c6x/include/generated/asm/current.h:1,
>                      from include/linux/sched.h:12,
>                      from include/linux/blkdev.h:5,
>                      from drivers//scsi/sd_zbc.c:11:
>     drivers//scsi/sd_zbc.c: In function 'sd_zbc_read_zones':
>>> include/linux/kernel.h:62:48: warning: 'zone_blocks' may be used
>     uninitialized in this function [-Wmaybe-uninitialized]
>      #define __round_mask(x, y) ((__typeof__(x))((y)-1))
>                                                     ^
>     drivers//scsi/sd_zbc.c:464:6: note: 'zone_blocks' was declared here
>       u32 zone_blocks;
>           ^~~~~~~~~~~
> 
> Fix this by initializing the zone_blocks variable to 0.

Probably worth noting that this is a false positive, and even if it is,
include a Fixes: entry as well.

Otherwise obviously looks fine to me. Martin, do you want to pick this
one up?
Martin K. Petersen July 16, 2019, 2:34 p.m. UTC | #2
Jens,

> Otherwise obviously looks fine to me. Martin, do you want to pick this
> one up?

Yep, I'll merge it.
Damien Le Moal July 17, 2019, 1:24 a.m. UTC | #3
On 2019/07/16 23:34, Martin K. Petersen wrote:
> 
> Jens,
> 
>> Otherwise obviously looks fine to me. Martin, do you want to pick this
>> one up?
> 
> Yep, I'll merge it.
> 

Martin,

Do you want me to send a new version with updated commit message and Fixes tag ?
Or will you fix that when applying ?

Best regards.
Martin K. Petersen July 17, 2019, 1:27 a.m. UTC | #4
Damien,

> Do you want me to send a new version with updated commit message and
> Fixes tag ?  Or will you fix that when applying ?

Please send me a tweaked one and I'll apply it right away.
diff mbox series

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index db16c19e05c4..5d6ff3931632 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -461,7 +461,7 @@  int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
 {
 	struct gendisk *disk = sdkp->disk;
 	unsigned int nr_zones;
-	u32 zone_blocks;
+	u32 zone_blocks = 0;
 	int ret;
 
 	if (!sd_is_zoned(sdkp))