mctp-demux-daemon: Resolve uninitialised variable warning
Multiple error paths in client_process_recv() failed to set rc before returning
it from the out_close label:
utils/mctp-demux-daemon.c: In function ‘main’:
utils/mctp-demux-daemon.c:457:7: error: ‘rc’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
457 | if (rc)
| ^
utils/mctp-demux-daemon.c:307:6: note: ‘rc’ was declared here
307 | int rc;
| ^~
cc1: all warnings being treated as errors
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I4196a2b5f7b242c53921040fead102525c92a286
diff --git a/utils/mctp-demux-daemon.c b/utils/mctp-demux-daemon.c
index da69210..d223279 100644
--- a/utils/mctp-demux-daemon.c
+++ b/utils/mctp-demux-daemon.c
@@ -327,6 +327,7 @@
len = recv(client->sock, NULL, 0, MSG_PEEK | MSG_TRUNC);
if (len < 0) {
warn("can't receive(peek) from client");
+ rc = -1;
goto out_close;
}
@@ -336,6 +337,7 @@
tmp = realloc(ctx->buf, len);
if (!tmp) {
warn("can't allocate for incoming message");
+ rc = -1;
goto out_close;
}
ctx->buf = tmp;
@@ -345,6 +347,7 @@
rc = recv(client->sock, ctx->buf, ctx->buf_size, 0);
if (rc < 0) {
warn("can't receive from client");
+ rc = -1;
goto out_close;
}