[PATCH 3/7] lib: sbi: sse: simplify 32bits overflow check

Anup Patel anup at brainfault.org
Tue May 7 01:49:38 PDT 2024


On Tue, Apr 9, 2024 at 3:32 PM Clément Léger <cleger at rivosinc.com> wrote:
>
> Rather than checking 32bits overflow with some absolute value, check the
> value to be different from the cast itself.
>
> Signed-off-by: Clément Léger <cleger at rivosinc.com>
> Reported-by: Samuel Holland <samuel.holland at sifive.com>

LGTM.

Reviewed-by: Anup Patel <anup at brainfault.org>

Regards,
Anup

> ---
>  lib/sbi/sbi_sse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_sse.c b/lib/sbi/sbi_sse.c
> index d54c125..cd8a539 100644
> --- a/lib/sbi/sbi_sse.c
> +++ b/lib/sbi/sbi_sse.c
> @@ -344,7 +344,7 @@ static int sse_event_set_attr_check(struct sbi_sse_event *e, uint32_t attr_id,
>                 break;
>         case SBI_SSE_ATTR_PRIO:
>  #if __riscv_xlen > 32
> -               if (val > 0xFFFFFFFFUL) {
> +               if (val != (uint32_t)val) {
>                         ret = SBI_EINVAL;
>                         break;
>                 }
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list