From c018d8e19e38b894392d5e06db10ae7b2e4df8f9 Mon Sep 17 00:00:00 2001 From: Jennifer Sutton Date: Mon, 19 May 2025 10:31:47 +1200 Subject: [PATCH] lib:async_req: Initialize variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ../../lib/async_req/async_sock.c: In function ‘writev_do’: ../../lib/async_req/async_sock.c:360:12: error: ‘written’ may be used uninitialized [-Werror=maybe-uninitialized] 360 | if ((written == -1) && | ^ ../../lib/async_req/async_sock.c:343:17: note: ‘written’ was declared here 343 | ssize_t written; | ^~~~~~~ ../../lib/async_req/async_sock.c: In function ‘read_packet_do’: ../../lib/async_req/async_sock.c:563:12: error: ‘nread’ may be used uninitialized [-Werror=maybe-uninitialized] 563 | if ((nread == -1) && (errno == EINTR)) { | ^ ../../lib/async_req/async_sock.c:531:17: note: ‘nread’ was declared here 531 | ssize_t nread, more; | ^~~~~ cc1: all warnings being treated as errors Signed-off-by: Jennifer Sutton Reviewed-by: Douglas Bagnall --- lib/async_req/async_sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index e90619056ed..b25d4cc3731 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -439,7 +439,7 @@ static bool writev_cancel(struct tevent_req *req) static void writev_do(struct tevent_req *req, struct writev_state *state) { - ssize_t written; + ssize_t written = -1; bool ok; if (state->is_sock) { @@ -627,7 +627,7 @@ static void read_packet_do(struct tevent_req *req, struct read_packet_state *state = tevent_req_data(req, struct read_packet_state); size_t total; - ssize_t nread, more; + ssize_t nread = -1, more; uint8_t *tmp; retry: -- 2.47.3