]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
gdbstub/user: localise variables for reading gdb socket
authorAlex Bennée <alex.bennee@linaro.org>
Tue, 3 Feb 2026 11:51:55 +0000 (11:51 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Fri, 6 Feb 2026 12:43:06 +0000 (12:43 +0000)
Keep things tidy by moving the declarations to the block where they
are used.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20260203115201.2387721-6-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
gdbstub/user.c

index 14369b9ce5eb358312420febd5c877009d4deddb..a16f37616b1e624cc6d00c1a07786c9a83a2a669 100644 (file)
@@ -198,9 +198,6 @@ void gdb_qemu_exit(int code)
 int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginfo,
                   int siginfo_len)
 {
-    char buf[256];
-    int n;
-
     if (!gdbserver_state.init || gdbserver_user_state.fd < 0) {
         return sig;
     }
@@ -246,11 +243,10 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginfo,
     gdbserver_state.state = RS_IDLE;
     gdbserver_user_state.running_state = 0;
     while (gdbserver_user_state.running_state == 0) {
-        n = read(gdbserver_user_state.fd, buf, 256);
+        char buf[256];
+        int n = read(gdbserver_user_state.fd, buf, 256);
         if (n > 0) {
-            int i;
-
-            for (i = 0; i < n; i++) {
+            for (int i = 0; i < n; i++) {
                 gdb_read_byte(buf[i]);
             }
         } else {