From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [RFC PATCH-for-10.2?] qemu/atomic: Silence -Wuninitialized warnings on macOS AArch64
Date: Tue, 2 Dec 2025 16:37:20 -0800 [thread overview]
Message-ID: <18424c93-6a81-43dd-bd81-3e0526ceb0f8@linaro.org> (raw)
In-Reply-To: <20251202183439.33259-1-philmd@linaro.org>
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~
prev parent reply other threads:[~2025-12-03 0:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18424c93-6a81-43dd-bd81-3e0526ceb0f8@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).