lkml.org 
[lkml]   [2004]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.045 / U:1.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site