On 4/24/19 3:31 PM, Richard W.M. Jones wrote:
GCC 9.0.1 isn't smart enough to work out that buf is initialized
on
all the relevant paths that lead to backend->pwrite being called. By
initializing it we can avoid the warning.
protocol.c: In function ‘protocol_recv_request_send_reply’:
protocol.c:241:9: error: ‘buf’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
241 | if (backend->pwrite (backend, conn, buf, count, offset, f, &err) ==
-1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protocol.c:614:9: note: ‘buf’ was declared here
614 | char *buf;
| ^~~
Wow - cross-function inlining evident in that error message. I agree
that it's a false positive; without your patch, buf can be passed to
handle_request() uninitialized, but never in the NBD_CMD_WRITE case,
even if the compiler can't spot that.
ACK.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org