lib: sbi: sse: simplify 32bits overflow check
authorClément Léger <cleger@rivosinc.com>
Tue, 9 Apr 2024 10:02:04 +0000 (12:02 +0200)
committerAnup Patel <anup@brainfault.org>
Tue, 7 May 2024 11:56:14 +0000 (17:26 +0530)
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@rivosinc.com>
Reported-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_sse.c

index 0f8b34767b8e48e0ac17c271482687bc0b402428..1b6048d852630bdc1af85114636c2cafc399f2af 100644 (file)
@@ -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;
                }