qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH-for-10.2?] qemu/atomic: Silence -Wuninitialized warnings on macOS AArch64
@ 2025-12-02 18:34 Philippe Mathieu-Daudé
  2025-12-03  0:37 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-12-02 18:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Richard Henderson, Philippe Mathieu-Daudé

Silence warning when building on macOS AArch64:

  C compiler for the host machine: clang (clang 17.0.0 "Apple clang version 17.0.0 (clang-1700.4.4.1)")
  Host machine cpu: aarch64
  ...
  In file included from ../../tcg/tcg.c:41:
  In file included from include/tcg/tcg-op-common.h:12:
  In file included from include/exec/helper-proto-common.h:10:
  In file included from include/qemu/atomic128.h:62:
  host/include/aarch64/host/atomic128-cas.h.inc:72:22: warning: variable 'tmpl' is uninitialized when used here [-Wuninitialized]
     72 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
        |                      ^~~~
  host/include/aarch64/host/atomic128-cas.h.inc:61:30: note: initialize the variable 'tmpl' to silence this warning
     61 |     uint64_t oldl, oldh, tmpl, tmph;
        |                              ^
        |                               = 0
  host/include/aarch64/host/atomic128-cas.h.inc:72:40: warning: variable 'tmph' is uninitialized when used here [-Wuninitialized]
     72 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
        |                                        ^~~~
  host/include/aarch64/host/atomic128-cas.h.inc:61:36: note: initialize the variable 'tmph' to silence this warning
     61 |     uint64_t oldl, oldh, tmpl, tmph;
        |                                    ^
        |                                     = 0
  host/include/aarch64/host/atomic128-cas.h.inc:92:22: warning: variable 'tmpl' is uninitialized when used here [-Wuninitialized]
     92 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
        |                      ^~~~
  host/include/aarch64/host/atomic128-cas.h.inc:81:30: note: initialize the variable 'tmpl' to silence this warning
     81 |     uint64_t oldl, oldh, tmpl, tmph;
        |                              ^
        |                               = 0
  host/include/aarch64/host/atomic128-cas.h.inc:92:40: warning: variable 'tmph' is uninitialized when used here [-Wuninitialized]
     92 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
        |                                        ^~~~
  host/include/aarch64/host/atomic128-cas.h.inc:81:36: note: initialize the variable 'tmph' to silence this warning
     81 |     uint64_t oldl, oldh, tmpl, tmph;
        |                                    ^
        |                                     = 0
  4 warnings generated.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 host/include/aarch64/host/atomic128-cas.h.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/host/include/aarch64/host/atomic128-cas.h.inc b/host/include/aarch64/host/atomic128-cas.h.inc
index aec27df1820..1334f467871 100644
--- a/host/include/aarch64/host/atomic128-cas.h.inc
+++ b/host/include/aarch64/host/atomic128-cas.h.inc
@@ -58,7 +58,7 @@ static inline Int128 atomic16_xchg(Int128 *ptr, Int128 new)
 static inline Int128 atomic16_fetch_and(Int128 *ptr, Int128 new)
 {
     uint64_t newl = int128_getlo(new), newh = int128_gethi(new);
-    uint64_t oldl, oldh, tmpl, tmph;
+    uint64_t oldl, oldh, tmpl = 0, tmph = 0;
     uint32_t tmp;
 
     asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t"
@@ -78,7 +78,7 @@ static inline Int128 atomic16_fetch_and(Int128 *ptr, Int128 new)
 static inline Int128 atomic16_fetch_or(Int128 *ptr, Int128 new)
 {
     uint64_t newl = int128_getlo(new), newh = int128_gethi(new);
-    uint64_t oldl, oldh, tmpl, tmph;
+    uint64_t oldl, oldh, tmpl = 0, tmph = 0;
     uint32_t tmp;
 
     asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t"
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH-for-10.2?] qemu/atomic: Silence -Wuninitialized warnings on macOS AArch64
  2025-12-02 18:34 [RFC PATCH-for-10.2?] qemu/atomic: Silence -Wuninitialized warnings on macOS AArch64 Philippe Mathieu-Daudé
@ 2025-12-03  0:37 ` Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2025-12-03  0:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Peter Maydell

On 12/2/25 10:34, Philippe Mathieu-Daudé wrote:
> Silence warning when building on macOS AArch64:
> 
>    C compiler for the host machine: clang (clang 17.0.0 "Apple clang version 17.0.0 (clang-1700.4.4.1)")
>    Host machine cpu: aarch64
>    ...
>    In file included from ../../tcg/tcg.c:41:
>    In file included from include/tcg/tcg-op-common.h:12:
>    In file included from include/exec/helper-proto-common.h:10:
>    In file included from include/qemu/atomic128.h:62:
>    host/include/aarch64/host/atomic128-cas.h.inc:72:22: warning: variable 'tmpl' is uninitialized when used here [-Wuninitialized]
>       72 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
>          |                      ^~~~
>    host/include/aarch64/host/atomic128-cas.h.inc:61:30: note: initialize the variable 'tmpl' to silence this warning
>       61 |     uint64_t oldl, oldh, tmpl, tmph;
>          |                              ^
>          |                               = 0
>    host/include/aarch64/host/atomic128-cas.h.inc:72:40: warning: variable 'tmph' is uninitialized when used here [-Wuninitialized]
>       72 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
>          |                                        ^~~~
>    host/include/aarch64/host/atomic128-cas.h.inc:61:36: note: initialize the variable 'tmph' to silence this warning
>       61 |     uint64_t oldl, oldh, tmpl, tmph;
>          |                                    ^
>          |                                     = 0
>    host/include/aarch64/host/atomic128-cas.h.inc:92:22: warning: variable 'tmpl' is uninitialized when used here [-Wuninitialized]
>       92 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
>          |                      ^~~~
>    host/include/aarch64/host/atomic128-cas.h.inc:81:30: note: initialize the variable 'tmpl' to silence this warning
>       81 |     uint64_t oldl, oldh, tmpl, tmph;
>          |                              ^
>          |                               = 0
>    host/include/aarch64/host/atomic128-cas.h.inc:92:40: warning: variable 'tmph' is uninitialized when used here [-Wuninitialized]
>       92 |           [tmpl] "r"(tmpl), [tmph] "r"(tmph)
>          |                                        ^~~~
>    host/include/aarch64/host/atomic128-cas.h.inc:81:36: note: initialize the variable 'tmph' to silence this warning
>       81 |     uint64_t oldl, oldh, tmpl, tmph;
>          |                                    ^
>          |                                     = 0
>    4 warnings generated.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   host/include/aarch64/host/atomic128-cas.h.inc | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/host/include/aarch64/host/atomic128-cas.h.inc b/host/include/aarch64/host/atomic128-cas.h.inc
> index aec27df1820..1334f467871 100644
> --- a/host/include/aarch64/host/atomic128-cas.h.inc
> +++ b/host/include/aarch64/host/atomic128-cas.h.inc
> @@ -58,7 +58,7 @@ static inline Int128 atomic16_xchg(Int128 *ptr, Int128 new)
>   static inline Int128 atomic16_fetch_and(Int128 *ptr, Int128 new)
>   {
>       uint64_t newl = int128_getlo(new), newh = int128_gethi(new);
> -    uint64_t oldl, oldh, tmpl, tmph;
> +    uint64_t oldl, oldh, tmpl = 0, tmph = 0;
>       uint32_t tmp;
>   
>       asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t"
> @@ -78,7 +78,7 @@ static inline Int128 atomic16_fetch_and(Int128 *ptr, Int128 new)
>   static inline Int128 atomic16_fetch_or(Int128 *ptr, Int128 new)
>   {
>       uint64_t newl = int128_getlo(new), newh = int128_gethi(new);
> -    uint64_t oldl, oldh, tmpl, tmph;
> +    uint64_t oldl, oldh, tmpl = 0, tmph = 0;
>       uint32_t tmp;
>   
>       asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t"

The warnings are correct and the assembly is wrong.
These should be outputs, not inputs.
Will fix.


r~


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-03  0:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 18:34 [RFC PATCH-for-10.2?] qemu/atomic: Silence -Wuninitialized warnings on macOS AArch64 Philippe Mathieu-Daudé
2025-12-03  0:37 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).