CC Helge Deller

Le 30/09/2024 à 10:14, marcandre.lur...@redhat.com a écrit :
From: Marc-André Lureau <marcandre.lur...@redhat.com>

../linux-user/hppa/cpu_loop.c: In function ‘hppa_lws’:
../linux-user/hppa/cpu_loop.c:106:17: error: ‘ret’ may be used uninitialized 
[-Werror=maybe-uninitialized]
   106 |     env->gr[28] = ret;

Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
---
  linux-user/hppa/cpu_loop.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index bc093b8fe8..f4da95490e 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -43,7 +43,7 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
          old = tswap32(old);
          new = tswap32(new);
          ret = qatomic_cmpxchg((uint32_t *)g2h(cs, addr), old, new);
-        ret = tswap32(ret);
+        env->gr[28] = tswap32(ret);
          break;
case 2: /* elf32 atomic "new" cmpxchg */
@@ -64,19 +64,19 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
              old = *(uint8_t *)g2h(cs, old);
              new = *(uint8_t *)g2h(cs, new);
              ret = qatomic_cmpxchg((uint8_t *)g2h(cs, addr), old, new);
-            ret = ret != old;
+            env->gr[28] = ret != old;
              break;
          case 1:
              old = *(uint16_t *)g2h(cs, old);
              new = *(uint16_t *)g2h(cs, new);
              ret = qatomic_cmpxchg((uint16_t *)g2h(cs, addr), old, new);
-            ret = ret != old;
+            env->gr[28] = ret != old;
              break;
          case 2:
              old = *(uint32_t *)g2h(cs, old);
              new = *(uint32_t *)g2h(cs, new);
              ret = qatomic_cmpxchg((uint32_t *)g2h(cs, addr), old, new);
-            ret = ret != old;
+            env->gr[28] = ret != old;
              break;
          case 3:
              {
@@ -97,13 +97,13 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
                  }
                  end_exclusive();
  #endif
+                env->gr[28] = ret;
              }
              break;
          }
          break;
      }
- env->gr[28] = ret;
      return 0;
  }

Did you try to put a g_assert_not_reached() in a "default:" for "switch(size)"?
This should help the compiler to know that "env->gr[28] = ret;" will not be 
reached if ret is not set.

Thanks,
Laurent


Reply via email to