[QUESTION] Usage of negative number notations on unsigned numbers.

Karthik B K karthik.bk at incoresemi.com
Fri Nov 24 01:36:07 PST 2023


Hi. The pmp_get function in lib/sbi/riscv_asm.c uses a negative number notation on an unsigned integer.

pmpaddr = -1UL;

Just curious why it is this way. I believe that the intention here is to represent the largest unsigned long number.
If so, isn't it safer to use (~0UL) ? This could be a very silent bug. Please correct me if I'm wrong.

Best,

karthik.


More information about the opensbi mailing list