From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Subject: Re: [PATCH] target/tricore: Use unsigned types for bitops in helper_eq_b()
Date: Tue, 23 Jul 2024 17:37:06 +0200 [thread overview]
Message-ID: <f3558004-946e-4620-924d-5e6e2402a259@linaro.org> (raw)
In-Reply-To: <20240723151042.1396610-1-peter.maydell@linaro.org>
On 23/7/24 17:10, Peter Maydell wrote:
> Coverity points out that in helper_eq_b() we have an int32_t 'msk'
> and we end up shifting into its sign bit. This is OK for QEMU because
> we use -fwrapv to give this well defined semantics, but when you look
> at what this function is doing it's doing bit operations, so we
> should be using an unsigned variable anyway. This also matches the
> return type of the function.
>
> Make 'ret' and 'msk' uint32_t.
>
> Resolves: Coverity CID 1547758
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/tricore/op_helper.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c
> index ba9c4444b39..a0d5a0da1df 100644
> --- a/target/tricore/op_helper.c
> +++ b/target/tricore/op_helper.c
> @@ -1505,8 +1505,8 @@ uint32_t helper_sub_h(CPUTriCoreState *env, target_ulong r1, target_ulong r2)
>
> uint32_t helper_eq_b(target_ulong r1, target_ulong r2)
> {
> - int32_t ret;
> - int32_t i, msk;
> + uint32_t ret, msk;
> + int32_t i;
We could even reduce 'i' scope to the for().
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2024-07-23 15:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 15:10 [PATCH] target/tricore: Use unsigned types for bitops in helper_eq_b() Peter Maydell
2024-07-23 15:37 ` Philippe Mathieu-Daudé [this message]
2024-07-23 23:28 ` Richard Henderson
2024-07-29 15:57 ` Peter Maydell
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=f3558004-946e-4620-924d-5e6e2402a259@linaro.org \
--to=philmd@linaro.org \
--cc=kbastian@mail.uni-paderborn.de \
--cc=peter.maydell@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).