Skip to contentSkip to conversation

linux-user: Fix uninitialized variables

PATCH New Peter Maydell 1 participant 3 messages Mar 12, 2014

lore
Share & tools
lore
#0 lore raw

cover linux-user: Fix uninitialized variables

Fix a couple of uses of uninitialized variables in linux-user; both spotted by clang as compile warnings.

Peter Maydell (2):
linux-user/signal.c: Correct error path for AArch64 do_rt_sigreturn
linux-user: Don't return uninitialized value for atomic_barrier
syscall

 linux-user/signal.c  | 2 +-
 linux-user/syscall.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/2 linux-user/signal.c: Correct error path for AArch64 do_rt_sigreturn

The error path in AArch64 do_rt_sigreturn() which fails before attempting lock_user_struct() was doing an unlock_user_struct() on an uninitialized variable. Initialize frame to NULL so we can use the same error-exit path in all cases (unlock of NULL is permitted and does nothing).

---
 linux-user/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/signal.c +1 -1
index c8a1da0..8c4a32d 100644
@@ -1334,7 +1334,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
 long do_rt_sigreturn(CPUARMState *env)
 {
-    struct target_rt_sigframe *frame;
+    struct target_rt_sigframe *frame = NULL;
     abi_ulong frame_addr = env->xregs[31];
 
     if (frame_addr & 15) {
Signature · 1 line
1.9.0
#2 lore raw

PATCH 2/2 linux-user: Don't return uninitialized value for atomic_barrier syscall

In reply to Peter Maydell

QEMU's implementation of the m68k atomic_barrier syscall, like the kernel's, is just a no-op. However we still need to return a result code from it.

---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
index e2c10cc..19317eb 100644
@@ -9142,6 +9142,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_atomic_barrier:
     {
         /* Like the kernel implementation and the qemu arm barrier, no-op this? */
+        ret = 0;
         break;
     }
 #endif
Signature · 1 line
1.9.0