All of lore.kernel.org
 help / color / mirror / Atom feed
* [QUESTION] Usage of negative number notations on unsigned numbers.
@ 2023-11-24  9:36 Karthik B K
  2023-11-24 11:08 ` Andreas Schwab
  0 siblings, 1 reply; 8+ messages in thread
From: Karthik B K @ 2023-11-24  9:36 UTC (permalink / raw)
  To: opensbi

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-28  6:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-24  9:36 [QUESTION] Usage of negative number notations on unsigned numbers Karthik B K
2023-11-24 11:08 ` Andreas Schwab
2023-11-27 11:59   ` Karthik B K
2023-11-27 12:09     ` Andreas Schwab
2023-11-27 12:55       ` Karthik B K
2023-11-27 13:46         ` Andreas Schwab
2023-11-28  5:28           ` Karthik B K
2023-11-28  6:01             ` Jessica Clarke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.