[PATCH 1/1] lib: utils/irqchip: plic: context_id is signed
Anup Patel
anup at brainfault.org
Mon Nov 10 00:19:13 PST 2025
On Wed, Nov 5, 2025 at 4:31 PM Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> Array context_id in struct plic_data has elements of type s16.
> A negative valid indicates an invalid entry.
> Copying the array element to a u32 scalar hides the sign.
>
> Use s16 as target type when copying an array element to a scalar.
>
> Addresses-Coverity-ID: 1667176 Unsigned compared against 0
> Addresses-Coverity-ID: 1667178 Logically dead code
> Addresses-Coverity-ID: 1667179 Unsigned compared against 0
> Addresses-Coverity-ID: 1667182 Logically dead code
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> lib/utils/irqchip/plic.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c
> index 581a41bb..7989a962 100644
> --- a/lib/utils/irqchip/plic.c
> +++ b/lib/utils/irqchip/plic.c
> @@ -136,7 +136,7 @@ void plic_suspend(void)
> return;
>
> sbi_for_each_hartindex(h) {
> - u32 context_id = plic->context_map[h][PLIC_S_CONTEXT];
> + s16 context_id = plic->context_map[h][PLIC_S_CONTEXT];
>
> if (context_id < 0)
> continue;
> @@ -167,7 +167,7 @@ void plic_resume(void)
> return;
>
> sbi_for_each_hartindex(h) {
> - u32 context_id = plic->context_map[h][PLIC_S_CONTEXT];
> + s16 context_id = plic->context_map[h][PLIC_S_CONTEXT];
>
> if (context_id < 0)
> continue;
> --
> 2.51.0
>
More information about the opensbi
mailing list