If the very first iteration of the loop breaks early due to the
dead QEMU process, 'ret' is never initialized. Ensure it is set
to -1 to represent an invalid FD number.

CID 1688281
Reported-by: Markus Armbruster <[email protected]>
Fixes: c12ad5378739 (qtest: fail fast when QEMU terminates early)
Signed-off-by: Daniel P. Berrangé <[email protected]>
---
 tests/qtest/libqtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 9e7a2d43a18..899727d6d35 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -121,7 +121,7 @@ static int qtest_socket_accept(QTestState *s, int sock)
 {
     struct sockaddr_un addr;
     socklen_t addrlen;
-    int ret;
+    int ret = -1;
     size_t i;
 #ifndef _WIN32
     struct timeval timeout = { .tv_sec = 0,
-- 
2.56.0


Reply via email to