Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1506088 > unrolled thread

[PATCH] block: zoned: fix harmless maybe-uninitialized warning

Started byArnd Bergmann <arnd@arndb.de>
First post2016-10-21 17:50 +0200
Last post2016-10-25 05:00 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] block: zoned: fix harmless maybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2016-10-21 17:50 +0200
    Re: [PATCH] block: zoned: fix harmless maybe-uninitialized warning Shaun Tancheff <shaun.tancheff@seagate.com> - 2016-10-21 22:50 +0200
    Re: [PATCH] block: zoned: fix harmless maybe-uninitialized warning "Martin K. Petersen" <martin.petersen@oracle.com> - 2016-10-25 03:10 +0200
      Re: [PATCH] block: zoned: fix harmless maybe-uninitialized warning Jens Axboe <axboe@kernel.dk> - 2016-10-25 05:00 +0200

#1506088 — [PATCH] block: zoned: fix harmless maybe-uninitialized warning

FromArnd Bergmann <arnd@arndb.de>
Date2016-10-21 17:50 +0200
Subject[PATCH] block: zoned: fix harmless maybe-uninitialized warning
Message-ID<suKeZ-7AT-5@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1506276

FromShaun Tancheff <shaun.tancheff@seagate.com>
Date2016-10-21 22:50 +0200
Message-ID<suOVj-2gP-3@gated-at.bofh.it>
In reply to#1506088
On Fri, Oct 21, 2016 at 10:42 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> 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

Reviewed-by: Shaun Tancheff <shaun.tancheff@seagate.com>

> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DQIBAg&c=IGDlg0lD0b-nebmJJ0Kp8A&r=Wg5NqlNlVTT7Ugl8V50qIHLe856QW0qfG3WVYGOrWzA&m=RyRS1pzTGdFENUb0PbQRSMAhvMgZx_dBftw2khYVIXU&s=p9SYS2a__p_YHv8FoZVz9kuTQQ7LIZBVKCkZuQgR0cs&e=



-- 
Shaun Tancheff

[toc] | [prev] | [next] | [standalone]


#1507899

From"Martin K. Petersen" <martin.petersen@oracle.com>
Date2016-10-25 03:10 +0200
Message-ID<svYpz-6Zw-3@gated-at.bofh.it>
In reply to#1506088
>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:

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

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

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

Jens: Are you picking up Arnd's two fixes for the zoned code?

-- 
Martin K. Petersen	Oracle Linux Engineering

[toc] | [prev] | [next] | [standalone]


#1507934

FromJens Axboe <axboe@kernel.dk>
Date2016-10-25 05:00 +0200
Message-ID<sw081-82K-3@gated-at.bofh.it>
In reply to#1507899
On 10/24/2016 07:00 PM, Martin K. Petersen wrote:
>>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:
>
> Arnd> The blkdev_report_zones produces a harmless warning when
> Arnd> -Wmaybe-uninitialized is set, after gcc gets a little confused
> Arnd> about the multiple 'goto' here:
>
> Arnd> block/blk-zoned.c: In function 'blkdev_report_zones':
> Arnd> block/blk-zoned.c:188:13: error: 'nz' may be used uninitialized in
> Arnd> this function [-Werror=maybe-uninitialized]
>
> Arnd> Moving the assignment to nr_zones makes this a little simpler
> Arnd> while also avoiding the warning reliably. I'm removing the
> Arnd> extraneous initialization of 'int ret' in the same patch, as that
> Arnd> is semi-related and could cause an uninitialized use of that
> Arnd> variable to not produce a warning.
>
> Jens: Are you picking up Arnd's two fixes for the zoned code?

Yep, adding them now. Thanks Arnd.

-- 
Jens Axboe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web