From: Peter Maydell <peter.maydell@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Cole Robinson" <crobinso@redhat.com>
Subject: Re: [PATCH v3 01/10] qemu/atomic: Use macros for CONFIG_ATOMIC64
Date: Mon, 19 Jul 2021 13:01:05 +0100 [thread overview]
Message-ID: <CAFEAcA8VMzowUJQL=ccTCHyc0wghMc+fQOXFTSRE56sZL4rNbw@mail.gmail.com> (raw)
In-Reply-To: <20210717192419.2066778-2-richard.henderson@linaro.org>
On Sat, 17 Jul 2021 at 20:24, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Clang warnings about questionable atomic usage get localized
> to the inline function in atomic.h. By using a macro, we get
> the full traceback to the original use that caused the warning.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/atomic.h | 25 +++++--------------------
> 1 file changed, 5 insertions(+), 20 deletions(-)
>
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index 3ccf84fd46..99d6030095 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -457,26 +457,11 @@
>
> /* Abstractions to access atomically (i.e. "once") i64/u64 variables */
> #ifdef CONFIG_ATOMIC64
> -static inline int64_t qatomic_read_i64(const int64_t *ptr)
> -{
> - /* use __nocheck because sizeof(void *) might be < sizeof(u64) */
> - return qatomic_read__nocheck(ptr);
> -}
> -
> -static inline uint64_t qatomic_read_u64(const uint64_t *ptr)
> -{
> - return qatomic_read__nocheck(ptr);
> -}
> -
> -static inline void qatomic_set_i64(int64_t *ptr, int64_t val)
> -{
> - qatomic_set__nocheck(ptr, val);
> -}
> -
> -static inline void qatomic_set_u64(uint64_t *ptr, uint64_t val)
> -{
> - qatomic_set__nocheck(ptr, val);
> -}
> +/* Use __nocheck because sizeof(void *) might be < sizeof(u64) */
> +#define qatomic_read_i64 qatomic_read__nocheck
> +#define qatomic_read_u64 qatomic_read__nocheck
> +#define qatomic_set_i64 qatomic_set__nocheck
> +#define qatomic_set_u64 qatomic_set__nocheck
Previously if you tried to do qatomic_set_i64() etc on something
that wasn't an int64_t*, the compiler would complain. Now it will
silently store a different-sized value, I think. Is there a way
to retain the typechecking in the macro versions?
thanks
-- PMM
next prev parent reply other threads:[~2021-07-19 12:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-17 19:24 [PATCH v3 00/10] Atomic cleanup + clang-12 build fix Richard Henderson
2021-07-17 19:24 ` [PATCH v3 01/10] qemu/atomic: Use macros for CONFIG_ATOMIC64 Richard Henderson
2021-07-19 12:01 ` Peter Maydell [this message]
2021-07-20 20:38 ` Richard Henderson
2021-07-17 19:24 ` [PATCH v3 02/10] qemu/atomic: Remove pre-C11 atomic fallbacks Richard Henderson
2021-07-19 12:05 ` Peter Maydell
2021-07-19 15:40 ` Alex Bennée
2021-07-17 19:24 ` [PATCH v3 03/10] qemu/atomic: Add aligned_{int64,uint64}_t types Richard Henderson
2021-07-19 12:39 ` Peter Maydell
2021-07-20 20:52 ` Richard Henderson
2021-07-17 19:24 ` [PATCH v3 04/10] tcg: Rename helper_atomic_*_mmu and provide for user-only Richard Henderson
2021-07-19 12:17 ` Peter Maydell
2021-07-17 19:24 ` [PATCH v3 05/10] accel/tcg: Standardize atomic helpers on softmmu api Richard Henderson
2021-07-19 12:19 ` Peter Maydell
2021-07-17 19:24 ` [PATCH v3 06/10] accel/tcg: Fold EXTRA_ARGS into atomic_template.h Richard Henderson
2021-07-19 12:19 ` Peter Maydell
2021-07-17 19:24 ` [PATCH v3 07/10] accel/tcg: Remove ATOMIC_MMU_DECLS Richard Henderson
2021-07-19 12:20 ` Peter Maydell
2021-07-17 19:24 ` [PATCH v3 08/10] accel/tcg: Expand ATOMIC_MMU_LOOKUP_* Richard Henderson
2021-07-19 12:22 ` Peter Maydell
2021-07-17 19:24 ` [PATCH v3 09/10] trace: Fold mem-internal.h into mem.h Richard Henderson
2021-07-19 12:26 ` Peter Maydell
2021-07-17 19:24 ` [PATCH v3 10/10] accel/tcg: Push trace info building into atomic_common.c.inc Richard Henderson
2021-07-19 12:25 ` Peter Maydell
2021-07-18 22:33 ` [PATCH v3 00/10] Atomic cleanup + clang-12 build fix Cole Robinson
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='CAFEAcA8VMzowUJQL=ccTCHyc0wghMc+fQOXFTSRE56sZL4rNbw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=crobinso@redhat.com \
--cc=f4bug@amsat.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).