[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] nbd: silence maybe-uninitialized warnings
From: |
Christian Borntraeger |
Subject: |
Re: [PATCH 2/4] nbd: silence maybe-uninitialized warnings |
Date: |
Mon, 5 Oct 2020 08:25:47 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH 2/4] nbd: silence maybe-uninitialized warnings,
Christian Borntraeger <=