"sparse" warnings..

linas at austin.ibm.com linas at austin.ibm.com
Tue May 4 03:34:27 EST 2004


On Sun, May 02, 2004 at 09:24:58PM -0700, Linus Torvalds wrote:
>
> Of course, in 99.9% of all cases, you'll never see anything strange, so

About a year ago, we fixed some real-live bugs due to comparisons to
"-1" done on unsigned quantities.  The original, buggy code looked
like this:

   inline u16 thingy (void) { ... if() return ~0; ... }

   if (thingy() == ~0) { ...}

The compare would fail ... the fix was to cast the const:

   if (thingy() == (u16) ~0) { ...}

I don't know if 'sparse' checks for this, but if it doesn't, it would
be nice if it did.  (Personally, I dislike ~0, but that's a different
matter).

--linas

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list