From: Eric Blake <eblake@redhat.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH 2/4] nbd: silence maybe-uninitialized warnings
Date: Wed, 30 Sep 2020 12:19:39 -0500 [thread overview]
Message-ID: <a6cf1fcd-cf09-08ed-774c-30f716b73cfa@redhat.com> (raw)
In-Reply-To: <20200930155859.303148-3-borntraeger@de.ibm.com>
[-- Attachment #1.1: Type: text/plain, Size: 1463 bytes --]
On 9/30/20 10:58 AM, Christian Borntraeger wrote:
> 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;
> | ^~~~~~~
> 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.
Reviewed-by: Eric Blake <eblake@redhat.com>
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.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-09-30 17:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 15:58 [PATCH 0/4] assorted gcc 10/fedora32 compile warning fixes Christian Borntraeger
2020-09-30 15:58 ` [PATCH 1/4] vmdk: fix maybe uninitialized warnings Christian Borntraeger
2020-09-30 16:36 ` Fam Zheng
2020-10-05 6:26 ` Christian Borntraeger
2020-10-12 14:16 ` Laurent Vivier
2020-09-30 15:58 ` [PATCH 2/4] nbd: silence maybe-uninitialized warnings Christian Borntraeger
2020-09-30 17:19 ` Eric Blake [this message]
2020-10-05 6:25 ` Christian Borntraeger
2020-09-30 15:58 ` [PATCH 3/4] qemu-io-cmds: avoid gcc 10 warning Christian Borntraeger
2020-09-30 16:24 ` Dr. David Alan Gilbert
2020-09-30 16:25 ` Philippe Mathieu-Daudé
2020-09-30 15:58 ` [PATCH 4/4] virtiofsd: avoid false positive compiler warning Christian Borntraeger
2020-09-30 16:27 ` Dr. David Alan Gilbert
2020-10-05 6:25 ` Christian Borntraeger
2020-09-30 18:12 ` [PATCH 0/4] assorted gcc 10/fedora32 compile warning fixes no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6cf1fcd-cf09-08ed-774c-30f716b73cfa@redhat.com \
--to=eblake@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=dgilbert@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).