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

Clément Léger cleger at rivosinc.com
Tue Apr 9 03:02:04 PDT 2024


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>
---
 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




More information about the opensbi mailing list