Messages in this thread | | | Date | Wed, 24 Nov 2004 00:28:46 +0100 (CET) | From | Jesper Juhl <> | Subject | Re: [PATCH] Remove pointless <0 comparison for unsigned variable in fs/fcntl.c |
| |
On Tue, 23 Nov 2004, Timur Tabi wrote:
> Jesper Juhl wrote: > > > My understanding of it is that it was just an example of how code that > > generated warnings about limited range of datatype could actually be > > perfectly fine. > > But if the example doesn't make any sense, then how does it prove the point? > How about this then; let's say that pid_t can be either 16 or 32 bits, and for some reason you want to handle something special if the value is greater than 0xffffff (or some other arbitrary value between 0xffff and 0xffffffff), obviously that can only happen in the cases where pid_t is 32 bit and never when it is only 16 bit, so code like
int foo(pid_t a) { if (a > 0xffffff) { ... } }
will generate warnings when pid_t is only 16 bit, but not when it is 32 bit, but the code will still do the correct thing in every case and is perfectly OK.
-- Jesper Juhl
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |