assorted gcc 10/fedora32 compile warning fixes
cover assorted gcc 10/fedora32 compile warning fixes
I might be wrong and some of these warnings could be correct, so some review from the subject matter experts would be good.
Christian Borntraeger (4):
vmdk: fix maybe uninitialized warnings
nbd: silence maybe-uninitialized warnings
qemu-io-cmds: avoid gcc 10 warning
virtiofsd: avoid false positive compiler warning
block/vmdk.c | 8 ++++---- nbd/server.c | 2 +- qemu-io-cmds.c | 4 +++- tools/virtiofsd/passthrough_ll.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/4 vmdk: fix maybe uninitialized warnings
Fedora 32 gcc 10 seems to give false positives:
Compiling C object libblock.fa.p/block_vmdk.c.o../block/vmdk.c: In function ‘vmdk_parse_extents’:../block/vmdk.c:587:5: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
587 | g_free(extent->l1_table);
| ^~~~~~~~~~~~~~~~~~~~~~~~
../block/vmdk.c:754:17: note: ‘extent’ was declared here
754 | VmdkExtent *extent;
| ^~~~~~
../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
620 | ret = vmdk_init_tables(bs, extent, errp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../block/vmdk.c:598:17: note: ‘extent’ was declared here
598 | VmdkExtent *extent;
| ^~~~~~
../block/vmdk.c:1178:39: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
1178 | extent->flat_start_offset = flat_offset << 9;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../block/vmdk.c: In function ‘vmdk_open_vmdk4’:
../block/vmdk.c:581:22: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
581 | extent->l2_cache =
| ~~~~~~~~~~~~~~~~~^
582 | g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../block/vmdk.c:872:17: note: ‘extent’ was declared here
872 | VmdkExtent *extent;
| ^~~~~~
../block/vmdk.c: In function ‘vmdk_open’:
../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
620 | ret = vmdk_init_tables(bs, extent, errp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../block/vmdk.c:598:17: note: ‘extent’ was declared here
598 | VmdkExtent *extent;
| ^~~~~~cc1: all warnings being treated as errors
make: *** [Makefile.ninja:884: libblock.fa.p/block_vmdk.c.o] Error 1
fix them by assigning a default value.
--- block/vmdk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/vmdk.c +4 -4
@@ -595,7 +595,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs,int ret;uint32_t magic;VMDK3Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret =bdrv_pread (file,sizeof (magic), &header,sizeof (header));if (ret <0 ) {
@@ -751,7 +751,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs,int ret;VMDKSESparseConstHeader const_header;VMDKSESparseVolatileHeader volatile_header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret =bdrv_apply_auto_read_only (bs,"No write support for seSparse images available" , errp);
@@ -869,7 +869,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,uint32_t magic;uint32_t l1_size, l1_entry_sectors;VMDK4Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;BDRVVmdkState *s = bs->opaque;int64_t l1_backup_offset =0 ;bool compressed;
@@ -1088,7 +1088,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,BdrvChild *extent_file;BdrvChildRole extent_role;BDRVVmdkState *s = bs->opaque; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;char extent_opt_prefix[32 ];Error *local_err =NULL ;
Signature · 1 line
2.26.2
Re: [PATCH 1/4] vmdk: fix maybe uninitialized warnings
Quoted 87 lines · Christian Borntraeger
Fedora 32 gcc 10 seems to give false positives:
Compiling C object
libblock.fa.p/block_vmdk.c.o../block/vmdk.c: In function ‘vmdk_parse_extents’:../block/vmdk.c:587:5: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]587 | g_free(extent->l1_table); | ^~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:754:17: note: ‘extent’ was declared here 754 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:1178:39: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1178 | extent->flat_start_offset = flat_offset << 9; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../block/vmdk.c: In function ‘vmdk_open_vmdk4’: ../block/vmdk.c:581:22: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 581 | extent->l2_cache = | ~~~~~~~~~~~~~~~~~^ 582 | g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ ../block/vmdk.c:872:17: note: ‘extent’ was declared here 872 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c: In function ‘vmdk_open’: ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~cc1: all warnings being treated as errors
make: *** [Makefile.ninja:884:libblock.fa.p/block_vmdk.c.o] Error 1fix them by assigning a default value.
Signed-off-by Christian Borntraeger <[email protected]>--- block/vmdk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)block/vmdk.c +1
-1@@ -595,7 +595,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, int ret;uint32_t magic;VMDK3Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret =bdrv_pread (file,sizeof (magic), &header,sizeof (header));if (ret < 0) {block/vmdk.c +1
-1@@ -751,7 +751,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, int ret;VMDKSESparseConstHeader const_header;VMDKSESparseVolatileHeader volatile_header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret = bdrv_apply_auto_read_only(bs,"No write support for seSparse images available", errp);block/vmdk.c +1
-1@@ -869,7 +869,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,uint32_t magic;uint32_t l1_size, l1_entry_sectors;VMDK4Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;BDRVVmdkState *s = bs->opaque;int64_t l1_backup_offset =0 ;bool compressed;
block/vmdk.c static int vmdk_parse_extents(const char *desc, · line 1094
Quoted 8 lines
block/vmdk.c +1
-1@@ -1088,7 +1088,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, BdrvChild *extent_file;BdrvChildRole extent_role;BDRVVmdkState *s = bs->opaque; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;char extent_opt_prefix[32 ];Error *local_err =NULL ;
Looks trivial, and correct.
Re: [PATCH 1/4] vmdk: fix maybe uninitialized warnings
Quoted 99 lines · Fam Zheng
Quoted 87 lines · Christian Borntraeger
Fedora 32 gcc 10 seems to give false positives:
Compiling C object
libblock.fa.p/block_vmdk.c.o../block/vmdk.c: In function ‘vmdk_parse_extents’:../block/vmdk.c:587:5: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]587 | g_free(extent->l1_table); | ^~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:754:17: note: ‘extent’ was declared here 754 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:1178:39: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1178 | extent->flat_start_offset = flat_offset << 9; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../block/vmdk.c: In function ‘vmdk_open_vmdk4’: ../block/vmdk.c:581:22: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 581 | extent->l2_cache = | ~~~~~~~~~~~~~~~~~^ 582 | g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ ../block/vmdk.c:872:17: note: ‘extent’ was declared here 872 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c: In function ‘vmdk_open’: ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~cc1: all warnings being treated as errors
make: *** [Makefile.ninja:884:libblock.fa.p/block_vmdk.c.o] Error 1fix them by assigning a default value.
Signed-off-by Christian Borntraeger <[email protected]>--- block/vmdk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)block/vmdk.c +1
-1@@ -595,7 +595,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, int ret;uint32_t magic;VMDK3Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret =bdrv_pread (file,sizeof (magic), &header,sizeof (header));if (ret < 0) {block/vmdk.c +1
-1@@ -751,7 +751,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, int ret;VMDKSESparseConstHeader const_header;VMDKSESparseVolatileHeader volatile_header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret = bdrv_apply_auto_read_only(bs,"No write support for seSparse images available", errp);block/vmdk.c +1
-1@@ -869,7 +869,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,uint32_t magic;uint32_t l1_size, l1_entry_sectors;VMDK4Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;BDRVVmdkState *s = bs->opaque;int64_t l1_backup_offset =0 ;bool compressed;block/vmdk.c static int vmdk_parse_extents(const char *desc, · line 1094
Quoted 8 lines
block/vmdk.c +1
-1@@ -1088,7 +1088,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, BdrvChild *extent_file;BdrvChildRole extent_role;BDRVVmdkState *s = bs->opaque; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;char extent_opt_prefix[32 ];Error *local_err =NULL ;Looks trivial, and correct.
Quoted 1 line
Reviewed-by Fam Zheng <[email protected]>
Will this go via the block or trivial tree (cced).
Laurent Vivier
AppliedRe: [PATCH 1/4] vmdk: fix maybe uninitialized warnings
Le 05/10/2020 à 08:26, Christian Borntraeger a écrit :
Quoted 100 lines · Fam Zheng
Quoted 99 lines · Christian Borntraeger
Quoted 87 lines
Fedora 32 gcc 10 seems to give false positives:
Compiling C object
libblock.fa.p/block_vmdk.c.o../block/vmdk.c: In function ‘vmdk_parse_extents’:../block/vmdk.c:587:5: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized]587 | g_free(extent->l1_table); | ^~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:754:17: note: ‘extent’ was declared here 754 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c:1178:39: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1178 | extent->flat_start_offset = flat_offset << 9; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../block/vmdk.c: In function ‘vmdk_open_vmdk4’: ../block/vmdk.c:581:22: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 581 | extent->l2_cache = | ~~~~~~~~~~~~~~~~~^ 582 | g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ ../block/vmdk.c:872:17: note: ‘extent’ was declared here 872 | VmdkExtent *extent; | ^~~~~~ ../block/vmdk.c: In function ‘vmdk_open’: ../block/vmdk.c:620:11: error: ‘extent’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 620 | ret = vmdk_init_tables(bs, extent, errp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../block/vmdk.c:598:17: note: ‘extent’ was declared here 598 | VmdkExtent *extent; | ^~~~~~cc1: all warnings being treated as errors
make: *** [Makefile.ninja:884:libblock.fa.p/block_vmdk.c.o] Error 1fix them by assigning a default value.
Signed-off-by Christian Borntraeger <[email protected]>--- block/vmdk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)block/vmdk.c +1
-1@@ -595,7 +595,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, int ret;uint32_t magic;VMDK3Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret =bdrv_pread (file,sizeof (magic), &header,sizeof (header));if (ret < 0) {block/vmdk.c +1
-1@@ -751,7 +751,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, int ret;VMDKSESparseConstHeader const_header;VMDKSESparseVolatileHeader volatile_header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ; ret = bdrv_apply_auto_read_only(bs,"No write support for seSparse images available", errp);block/vmdk.c +1
-1@@ -869,7 +869,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,uint32_t magic;uint32_t l1_size, l1_entry_sectors;VMDK4Header header; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;BDRVVmdkState *s = bs->opaque;int64_t l1_backup_offset =0 ;bool compressed;block/vmdk.c static int vmdk_parse_extents(const char *desc, · line 1094
Quoted 8 lines
block/vmdk.c +1
-1@@ -1088,7 +1088,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, BdrvChild *extent_file;BdrvChildRole extent_role;BDRVVmdkState *s = bs->opaque; -VmdkExtent *extent; +VmdkExtent *extent =NULL ;char extent_opt_prefix[32 ];Error *local_err =NULL ;Looks trivial, and correct.
Quoted 5 lines
Quoted 1 line
Reviewed-by Fam Zheng <[email protected]>Will this go via the block or trivial tree (cced).
Applied to my trivial-patches branch.
Thanks,
Laurent
PATCH 2/4 nbd: silence maybe-uninitialized warnings
In reply to Christian Borntraegergcc 10 from Fedora 32 gives me:
Compiling C object libblock.fa.p/nbd_server.c.o../nbd/server.c: In function ‘nbd_co_client_start’:../nbd/server.c:625:14: error: ‘namelen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
625 | rc = nbd_negotiate_send_info(client, NBD_INFO_NAME, namelen, name,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
626 | errp);
| ~~~~~
../nbd/server.c:564:14: note: ‘namelen’ was declared here
564 | uint32_t namelen;
| ^~~~~~~cc1: all warnings being treated as errors
As I cannot see how this can happen, let uns silence the warning.
--- nbd/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nbd/server.c +1 -1
@@ -561,7 +561,7 @@ static int nbd_negotiate_handle_info(NBDClient *client, Error **errp)NBDExport *exp;uint16_t requests;uint16_t request; -uint32_t namelen; +uint32_t namelen =0 ;bool sendname = false;bool blocksize = false;uint32_t sizes[3 ];
Signature · 1 line
2.26.2
Re: [PATCH 2/4] nbd: silence maybe-uninitialized warnings
Quoted 12 lines · Christian Borntraeger
gcc 10 from Fedora 32 gives me:
Compiling C object
libblock.fa.p/nbd_server.c.o../nbd/server.c: In function ‘nbd_co_client_start’:../nbd/server.c:625:14: error: ‘namelen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]625 | rc = nbd_negotiate_send_info(client, NBD_INFO_NAME, namelen, name, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 626 | errp); | ~~~~~ ../nbd/server.c:564:14: note: ‘namelen’ was declared here 564 | uint32_t namelen; | ^~~~~~~
Quoted 3 lines
cc1: all warnings being treated as errors
As I cannot see how this can happen, let uns silence the warning.
gcc is smart enough to see that nbd_opt_read_name(... &namelen), which is the only use of namelen between declaration and use, does not always initialize namelen; but fails to see we also exit this function early in the same conditions when nbd_opt_read_name left namelen uninit. The workaround is fine.
I'm happy for this to go in through the trivial tree, but I'll also queue it on my NBD tree if that is ready first.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH 2/4] nbd: silence maybe-uninitialized warnings
Quoted 23 lines · Eric Blake
Quoted 12 lines · Christian Borntraeger
gcc 10 from Fedora 32 gives me:
Compiling C object
libblock.fa.p/nbd_server.c.o../nbd/server.c: In function ‘nbd_co_client_start’:../nbd/server.c:625:14: error: ‘namelen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]625 | rc = nbd_negotiate_send_info(client, NBD_INFO_NAME, namelen, name, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 626 | errp); | ~~~~~ ../nbd/server.c:564:14: note: ‘namelen’ was declared here 564 | uint32_t namelen; | ^~~~~~~Quoted 3 lines
cc1: all warnings being treated as errors
As I cannot see how this can happen, let uns silence the warning.
gcc is smart enough to see that nbd_opt_read_name(... &namelen), which is the only use of namelen between declaration and use, does not always initialize namelen; but fails to see we also exit this function early in the same conditions when
nbd_opt_read_nameleft namelen uninit. The workaround is fine.
Quoted 4 lines
Reviewed-by Eric Blake <[email protected]>I'm happy for this to go in through the trivial tree, but I'll also queue it on my NBD tree if that is ready first.
Just in case cc qemu-trival.
PATCH 3/4 qemu-io-cmds: avoid gcc 10 warning
In reply to Christian BorntraegerWith gcc 10 on Fedora32 I do get:
Compiling C object libblock.fa.p/qemu-io-cmds.c.o
In file included from /usr/include/stdio.h:867,
from /home/cborntra/REPOS/qemu/include/qemu/osdep.h:85,
from ../qemu-io-cmds.c:11:
In function ‘printf’,
inlined from ‘help_oneline’ at ../qemu-io-cmds.c:2389:9,
inlined from ‘help_all’ at ../qemu-io-cmds.c:2414:9,
inlined from ‘help_f’ at ../qemu-io-cmds.c:2424:9:
/usr/include/bits/stdio2.h:107:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
107 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
Let us check for null.
--- qemu-io-cmds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
qemu-io-cmds.c +3 -1
@@ -2386,7 +2386,9 @@ static void help_oneline(const char *cmd, const cmdinfo_t *ct)if (cmd) {printf ("%s " , cmd); }else { -printf ("%s " , ct->name); +if (ct->name) { +printf ("%s " , ct->name); + }if (ct->altname) {printf ("(or %s) " , ct->altname); }
Signature · 1 line
2.26.2
Re: [PATCH 3/4] qemu-io-cmds: avoid gcc 10 warning
Quoted 28 lines · Christian Borntraeger
With gcc 10 on Fedora32 I do get:
Compiling C object
libblock.fa.p/qemu-io-cmds.c.o
In file included from/usr/include/stdio.h:867,from /home/cborntra/REPOS/qemu/include/qemu/osdep.h:85, from ../qemu-io-cmds.c:11: In function ‘printf’, inlined from ‘help_oneline’ at ../qemu-io-cmds.c:2389:9, inlined from ‘help_all’ at ../qemu-io-cmds.c:2414:9, inlined from ‘help_f’ at ../qemu-io-cmds.c:2424:9: /usr/include/bits/stdio2.h:107:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 107 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
Let us check for null.
Signed-off-by Christian Borntraeger <[email protected]>--- qemu-io-cmds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)qemu-io-cmds.c +0
-0
qemu-io-cmds.c static void help_oneline(const char *cmd, const cmdinfo_t *ct) · line 2394
Quoted 10 lines
qemu-io-cmds.c +3
-1@@ -2386,7 +2386,9 @@ static void help_oneline(const char *cmd, const cmdinfo_t *ct)if (cmd) {printf ("%s " , cmd); }else { -printf ("%s " , ct->name); +if (ct->name) { +printf ("%s " , ct->name); + }if (ct->altname) {printf ("(or %s) " , ct->altname); }
This one has been fixed last month:
https://www.mail-archive.com/[email protected]/msg732728.html
Then queued recently:
https://www.mail-archive.com/[email protected]/msg745394.html
Re: [PATCH 3/4] qemu-io-cmds: avoid gcc 10 warning
In reply to Christian BorntraegerQuoted 13 lines · * Christian Borntraeger ([email protected]) wrote:
With gcc 10 on Fedora32 I do get:
Compiling C object
libblock.fa.p/qemu-io-cmds.c.o
In file included from/usr/include/stdio.h:867,from /home/cborntra/REPOS/qemu/include/qemu/osdep.h:85, from ../qemu-io-cmds.c:11: In function ‘printf’, inlined from ‘help_oneline’ at ../qemu-io-cmds.c:2389:9, inlined from ‘help_all’ at ../qemu-io-cmds.c:2414:9, inlined from ‘help_f’ at ../qemu-io-cmds.c:2424:9: /usr/include/bits/stdio2.h:107:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 107 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 5 lines
cc1: all warnings being treated as errors
Let us check for null.
Signed-off-by Christian Borntraeger <[email protected]>
I'd already posted
'qemu-io-cmds: Simplify help_oneline' that simplifies this function much more; Kevin picked that up for the block branch a couple of days ago.
Dave
Quoted 22 lines
--- qemu-io-cmds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)qemu-io-cmds.c +3
-1@@ -2386,7 +2386,9 @@ static void help_oneline(const char *cmd, const cmdinfo_t *ct)if (cmd) {printf ("%s " , cmd); }else { -printf ("%s " , ct->name); +if (ct->name) { +printf ("%s " , ct->name); + }if (ct->altname) {printf ("(or %s) " , ct->altname); }Signature · 1 line
2.26.2
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 4/4 virtiofsd: avoid false positive compiler warning
In reply to Christian Borntraegermake: *** [Makefile:121: config-host.mak] Error 1
[cborntra@m83lp52 qemu]$ make -C build/
make: Entering directory '/home/cborntra/REPOS/qemu/build'
Generating qemu-version.h with a meson_exe.py custom command
Compiling C object tools/virtiofsd/virtiofsd.p/passthrough_ll.c.o../tools/virtiofsd/passthrough_ll.c: In function ‘lo_setattr’:../tools/virtiofsd/passthrough_ll.c:702:19: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
702 | res = futimens(fd, tv);
| ^~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make: *** [Makefile.ninja:1438: tools/virtiofsd/virtiofsd.p/passthrough_ll.c.o] Error 1
make: Leaving directory '/home/cborntra/REPOS/
as far as I can see this can not happen. Let us silence the warning by giving fd a default value.
--- tools/virtiofsd/passthrough_ll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtiofsd/passthrough_ll.c +1 -1
@@ -620,7 +620,7 @@ static void lo_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,struct lo_inode *inode;int ifd;int res; -int fd; +int fd =0 ; inode =lo_inode (req, ino);if (!inode) {
Signature · 1 line
2.26.2
Re: [PATCH 4/4] virtiofsd: avoid false positive compiler warning
Quoted 9 lines · * Christian Borntraeger ([email protected]) wrote:
make: *** [Makefile:121: config-host.mak] Error 1
[cborntra@m83lp52 qemu]$ make -C build/
make: Entering directory '/home/cborntra/REPOS/qemu/build'
Generatingqemu-version.hwith ameson_exe.pycustom command
Compiling C objecttools/virtiofsd/virtiofsd.p/passthrough_ll.c.o../tools/virtiofsd/passthrough_ll.c: In function ‘lo_setattr’:../tools/virtiofsd/passthrough_ll.c:702:19: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]702 | res = futimens(fd, tv); | ^~~~~~~~~~~~~~~~
Quoted 8 lines
cc1: all warnings being treated as errors
make: *** [Makefile.ninja:1438:tools/virtiofsd/virtiofsd.p/passthrough_ll.c.o] Error 1
make: Leaving directory '/home/cborntra/REPOS/as far as I can see this can not happen. Let us silence the warning by giving fd a default value.
Signed-off-by Christian Borntraeger <[email protected]>
Yeh, I'd posted https://www.mail-archive.com/[email protected]/msg738783.html
but not yet merged it; only difference is I'd used -1 since it seemd safer to use -1 even if it couldn't happen :-)
Dave
Quoted 20 lines
--- tools/virtiofsd/passthrough_ll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/virtiofsd/passthrough_ll.c +1
-1@@ -620,7 +620,7 @@ static void lo_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,struct lo_inode *inode;int ifd;int res; -int fd; +int fd =0 ; inode =lo_inode (req, ino);if (!inode) {Signature · 1 line
2.26.2
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 4/4] virtiofsd: avoid false positive compiler warning
Quoted 14 lines · Dr. David Alan Gilbert
Quoted 13 lines · * Christian Borntraeger ([email protected]) wrote:
make: *** [Makefile:121: config-host.mak] Error 1
[cborntra@m83lp52 qemu]$ make -C build/
make: Entering directory '/home/cborntra/REPOS/qemu/build'
Generatingqemu-version.hwith ameson_exe.pycustom command
Compiling C objecttools/virtiofsd/virtiofsd.p/passthrough_ll.c.o../tools/virtiofsd/passthrough_ll.c: In function ‘lo_setattr’:../tools/virtiofsd/passthrough_ll.c:702:19: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]702 | res = futimens(fd, tv); | ^~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make: *** [Makefile.ninja:1438:tools/virtiofsd/virtiofsd.p/passthrough_ll.c.o] Error 1
make: Leaving directory '/home/cborntra/REPOS/
Quoted 8 lines
Quoted 4 lines
as far as I can see this can not happen. Let us silence the warning by giving fd a default value.
Signed-off-by Christian Borntraeger <[email protected]>Yeh, I'd posted https://www.mail-archive.com/[email protected]/msg738783.html
but not yet merged it; only difference is I'd used -1 since it seemd safer to use -1 even if it couldn't happen :-)
Agreed, lets go with your patch.
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH 0/4] assorted gcc 10/fedora32 compile warning fixes
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected] - [tag update] patchew/[email protected] -> patchew/[email protected] - [tag update] patchew/[email protected] -> patchew/[email protected] - [tag update] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected]
fatal: failed to write ref-pack file
fatal: The remote end hung up unexpectedly
Traceback (most recent call last):
File "patchew-tester/src/patchew-cli", line 521, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf, True)
File "patchew-tester/src/patchew-cli", line 53, in git_clone_repo
subprocess.check_call(clone_cmd, stderr=logf, stdout=logf)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'clone', '-q', '/home/patchew/.cache/patchew-git-cache/httpsgithubcompatchewprojectqemu-3c8cf5a9c21ff8782164d1def7f44bd888713384', '/var/tmp/patchew-tester-tmp-529h9bha/src']' returned non-zero exit status 128.
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]