qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/1] block/file-posix: Avoid maybe-uninitialized warning
@ 2024-08-12 14:43 Edgar E. Iglesias
  2024-08-12 14:43 ` [PATCH v1 1/1] " Edgar E. Iglesias
  0 siblings, 1 reply; 4+ messages in thread
From: Edgar E. Iglesias @ 2024-08-12 14:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, hreitz, edgar.iglesias, qemu-block

From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>

Hi,

I ran into the following build-warning when building QEMU
with GCC 14.1.0:
[925/1857] Compiling C object libblock.a.p/block_file-posix.c.o
FAILED: libblock.a.p/block_file-posix.c.o 
aarch64-poky-linux-gcc -mcpu=cortex-a57+crc -mbranch-protection=standard -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/yoxen/arm64/sysroots/cortexa57-poky-linux -Ilibblock.a.p -I. -I../qemu -Iqapi -Itrace -Iui -Iui/shader -Iblock -I/opt/yoxen/arm64/sysroots/cortexa57-poky-linux/usr/include/glib-2.0 -I/opt/yoxen/arm64/sysroots/cortexa57-poky-linux/usr/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/edgar/src/c/qemu/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/edgar/src/c/qemu/qemu -iquote /home/edgar/src/c/qemu/qemu/include -iquote /home/edgar/src/c/qemu/qemu/host/include/aarch64 -iquote /home/edgar/src/c/qemu/qemu/host/include/generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -O2 -pipe -g -feliminate-unused-debug-types -Os -fPIE -MD -MQ libblock.a.p/block_file-posix.c.o -MF libblock.a.p/block_file-posix.c.o.d -o libblock.a.p/block_file-posix.c.o -c ../qemu/block/file-posix.c
In function ‘raw_refresh_zoned_limits’,
    inlined from ‘raw_refresh_limits’ at ../qemu/block/file-posix.c:1522:5:
../qemu/block/file-posix.c:1405:17: error: ‘zoned’ may be used uninitialized [-Werror=maybe-uninitialized]
 1405 |     if (ret < 0 || zoned == BLK_Z_NONE) {
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../qemu/block/file-posix.c:1401:20: note: ‘zoned’ was declared here
 1401 |     BlockZoneModel zoned;
      |                    ^~~~~
cc1: all warnings being treated as errors

It looks like a false positive and this fix avoids the warning.

Cheers,
Edgar

Edgar E. Iglesias (1):
  block/file-posix: Avoid maybe-uninitialized warning

 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.43.0



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

* [PATCH v1 1/1] block/file-posix: Avoid maybe-uninitialized warning
  2024-08-12 14:43 [PATCH v1 0/1] block/file-posix: Avoid maybe-uninitialized warning Edgar E. Iglesias
@ 2024-08-12 14:43 ` Edgar E. Iglesias
  2024-08-14 18:15   ` Eric Blake
  0 siblings, 1 reply; 4+ messages in thread
From: Edgar E. Iglesias @ 2024-08-12 14:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, hreitz, edgar.iglesias, qemu-block

From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>

Avoid a maybe-uninitialized warning in raw_refresh_zoned_limits()
by initializing zoned.

With GCC 14.1.0:
In function ‘raw_refresh_zoned_limits’,
    inlined from ‘raw_refresh_limits’ at ../qemu/block/file-posix.c:1522:5:
../qemu/block/file-posix.c:1405:17: error: ‘zoned’ may be used uninitialized [-Werror=maybe-uninitialized]
 1405 |     if (ret < 0 || zoned == BLK_Z_NONE) {
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../qemu/block/file-posix.c:1401:20: note: ‘zoned’ was declared here
 1401 |     BlockZoneModel zoned;
      |                    ^~~~~
cc1: all warnings being treated as errors

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index ff928b5e85..90fa54352c 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1398,7 +1398,7 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st,
                                      Error **errp)
 {
     BDRVRawState *s = bs->opaque;
-    BlockZoneModel zoned;
+    BlockZoneModel zoned = BLK_Z_NONE;
     int ret;
 
     ret = get_sysfs_zoned_model(st, &zoned);
-- 
2.43.0



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

* Re: [PATCH v1 1/1] block/file-posix: Avoid maybe-uninitialized warning
  2024-08-12 14:43 ` [PATCH v1 1/1] " Edgar E. Iglesias
@ 2024-08-14 18:15   ` Eric Blake
  2024-09-23 16:06     ` Edgar E. Iglesias
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Blake @ 2024-08-14 18:15 UTC (permalink / raw)
  To: Edgar E. Iglesias; +Cc: qemu-devel, kwolf, hreitz, edgar.iglesias, qemu-block

On Mon, Aug 12, 2024 at 04:43:23PM GMT, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
> 
> Avoid a maybe-uninitialized warning in raw_refresh_zoned_limits()
> by initializing zoned.
> 
> With GCC 14.1.0:
> In function ‘raw_refresh_zoned_limits’,
>     inlined from ‘raw_refresh_limits’ at ../qemu/block/file-posix.c:1522:5:
> ../qemu/block/file-posix.c:1405:17: error: ‘zoned’ may be used uninitialized [-Werror=maybe-uninitialized]
>  1405 |     if (ret < 0 || zoned == BLK_Z_NONE) {
>       |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
> ../qemu/block/file-posix.c:1401:20: note: ‘zoned’ was declared here
>  1401 |     BlockZoneModel zoned;
>       |                    ^~~~~
> cc1: all warnings being treated as errors
> 
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> ---
>  block/file-posix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index ff928b5e85..90fa54352c 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1398,7 +1398,7 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st,
>                                       Error **errp)
>  {
>      BDRVRawState *s = bs->opaque;
> -    BlockZoneModel zoned;
> +    BlockZoneModel zoned = BLK_Z_NONE;
>      int ret;
>  
>      ret = get_sysfs_zoned_model(st, &zoned);
> -- 
> 2.43.0
> 
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org



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

* Re: [PATCH v1 1/1] block/file-posix: Avoid maybe-uninitialized warning
  2024-08-14 18:15   ` Eric Blake
@ 2024-09-23 16:06     ` Edgar E. Iglesias
  0 siblings, 0 replies; 4+ messages in thread
From: Edgar E. Iglesias @ 2024-09-23 16:06 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, kwolf, hreitz, edgar.iglesias, qemu-block

Ping!

On Wed, Aug 14, 2024 at 01:15:55PM -0500, Eric Blake wrote:
> On Mon, Aug 12, 2024 at 04:43:23PM GMT, Edgar E. Iglesias wrote:
> > From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
> > 
> > Avoid a maybe-uninitialized warning in raw_refresh_zoned_limits()
> > by initializing zoned.
> > 
> > With GCC 14.1.0:
> > In function ‘raw_refresh_zoned_limits’,
> >     inlined from ‘raw_refresh_limits’ at ../qemu/block/file-posix.c:1522:5:
> > ../qemu/block/file-posix.c:1405:17: error: ‘zoned’ may be used uninitialized [-Werror=maybe-uninitialized]
> >  1405 |     if (ret < 0 || zoned == BLK_Z_NONE) {
> >       |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
> > ../qemu/block/file-posix.c:1401:20: note: ‘zoned’ was declared here
> >  1401 |     BlockZoneModel zoned;
> >       |                    ^~~~~
> > cc1: all warnings being treated as errors
> > 
> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
> > ---
> >  block/file-posix.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> > 
> > diff --git a/block/file-posix.c b/block/file-posix.c
> > index ff928b5e85..90fa54352c 100644
> > --- a/block/file-posix.c
> > +++ b/block/file-posix.c
> > @@ -1398,7 +1398,7 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st,
> >                                       Error **errp)
> >  {
> >      BDRVRawState *s = bs->opaque;
> > -    BlockZoneModel zoned;
> > +    BlockZoneModel zoned = BLK_Z_NONE;
> >      int ret;
> >  
> >      ret = get_sysfs_zoned_model(st, &zoned);
> > -- 
> > 2.43.0
> > 
> > 
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.
> Virtualization:  qemu.org | libguestfs.org
> 


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

end of thread, other threads:[~2024-09-23 16:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 14:43 [PATCH v1 0/1] block/file-posix: Avoid maybe-uninitialized warning Edgar E. Iglesias
2024-08-12 14:43 ` [PATCH v1 1/1] " Edgar E. Iglesias
2024-08-14 18:15   ` Eric Blake
2024-09-23 16:06     ` Edgar E. Iglesias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).