[lkml]   [2004]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] Remove pointless <0 comparison for unsigned variable in fs/fcntl.c

    On Tue, 23 Nov 2004, Jesper Juhl wrote:
    > Linus, would you accept patches like this?

    No, please don't.

    The warning is sometimes useful, but when it comes to a construct like

    if (a < 0 || a > X)

    the fact that "a" is unsigned does not make the construct silly. First
    off, it's (a) very readable and (b) the type of "a" may not be immediately
    obvious if it's a user typedef, for example.

    In fact, the type of "a" might depend on the architecture, or even
    compiler flags. Think about "char" - which may or may not be signed
    depending on ABI and things like -funsigned-char.

    In other places, it's not "unsigned" that is the problem, but the fact
    that the range of a type is smaller on one architecture than another. So
    you might have

    inf fn(pid_t a)
    if (a > 0xffff)

    which might warn on an architecture where "pid_t" is just sixteen bits
    wide. Does that make the code wrong? Hell no.

    IOW, a lot of the gcc warnings are just not valid, and trying to shut gcc
    up about them can break (and _has_ broken) code that was correct before.

    > I probably won't be able to properly evaluate/review *all* the instances
    > of this in the kernel,

    It's not even that I will drop the patches, it's literally that "fixing"
    the code so that gcc doesn't complain can be a BUG. We've gone through

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2009-11-18 23:46    [W:0.029 / U:14.452 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site