qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, qemu-trivial@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: Mon, 5 Oct 2020 08:25:47 +0200	[thread overview]
Message-ID: <e1d1d60d-7df1-5152-a4a6-7f121b5f76f5@de.ibm.com> (raw)
In-Reply-To: <a6cf1fcd-cf09-08ed-774c-30f716b73cfa@redhat.com>

On 30.09.20 19:19, Eric Blake wrote:
> 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.

Just in case cc qemu-trival. 


  reply	other threads:[~2020-10-05  6:28 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
2020-10-05  6:25     ` Christian Borntraeger [this message]
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=e1d1d60d-7df1-5152-a4a6-7f121b5f76f5@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@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=qemu-trivial@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).