gcc has a false positive warning, which fails a build with -Werror:
nbd.c: In function ‘nbd_reply’:
nbd.c:306:19: error: ‘trans.cookie’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
assert (err < 0 || cookie == trans.cookie);
^~
cc1: all warnings being treated as errors
The problem is that gcc can't tell that nbd_reply_raw()'s early
return path via nbd_mark_dead() prior to initializing trans
will always set err to a negative value. Help it out by manually
initializing trans.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing as the obvious fix for the warning.
plugins/nbd/nbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index c3ca4ed..739eecd 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -300,7 +300,7 @@ static int
nbd_reply (struct handle *h, int cookie)
{
int err;
- struct transaction trans;
+ struct transaction trans = { 0 };
err = nbd_reply_raw (h, &trans);
assert (err < 0 || cookie == trans.cookie);
--
2.13.6