From: "Alex Bennée" <alex.bennee@linaro.org>
To: Sergey Mironov <mironov@fintech.ru>
Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/1] target/arm: Adding a check for the result of calling the CPU information check function
Date: Thu, 12 Oct 2023 16:16:11 +0100 [thread overview]
Message-ID: <87pm1jn9xk.fsf@linaro.org> (raw)
In-Reply-To: <20231012085710.880440-1-mironov@fintech.ru>
Sergey Mironov <mironov@fintech.ru> writes:
> 6 out of 7 calls to get_arm_cp_reginfo() are checked
Yes but we should be careful with asserts (vs if (ri) legs) because I
don't think get_arm_cp_reginfo() guarantees it will always be
successful.
>
> Signed-off-by: Sergey Mironov <mironov@fintech.ru>
> ---
> target/arm/helper.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/target/arm/helper.c b/target/arm/helper.c
> index 74fbb6e1d7..cffbbaf571 100644
> --- a/target/arm/helper.c
> +++ b/target/arm/helper.c
> @@ -198,6 +198,7 @@ static void add_cpreg_to_list(gpointer key, gpointer opaque)
> uint32_t regidx = (uintptr_t)key;
> const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
>
> + assert(ri != NULL);
/* must always succeed as we are iterating the keys of cp_regs */
assert(ri);
is enough for a !NULL check.
> if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) {
> cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx);
> /* The value array need not be initialized at this point */
That said we already have an assert that would fire in
init_cpregs_list():
assert(cpu->cpreg_array_len == arraylen);
so I'm not sure what this is adding to ensuring the contract is kept.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2023-10-12 15:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 8:57 [PATCH 1/1] target/arm: Adding a check for the result of calling the CPU information check function Sergey Mironov
2023-10-12 15:16 ` Alex Bennée [this message]
2023-10-16 16:23 ` Peter Maydell
2023-10-17 7:48 ` Миронов Сергей Владимирович
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=87pm1jn9xk.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=mironov@fintech.ru \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.