lkml.org 
[lkml]   [2001]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [IDEA+RFC] Possible solution for min()/max() war

    On Thu, 30 Aug 2001, Roman Zippel wrote:
    >
    > So why won't you let the compiler help you, even if it's not perfect in
    > every case?

    I considered enabling -Wsign-compare a long time ago, and it's not a
    question of being "perfect", but a question of being _so_ broken that it's
    not funny.

    For example, let's look at this perfectly natural code:

    static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
    {
    if (len <= sizeof(short) || len > sizeof(*sunaddr))
    return -EINVAL;
    ...

    Would you agree that the above is _good_ code, and code that makes
    perfect sense, and code that does exactly the right thing in testing its
    arguments?

    Try to compile it with -Wsign-compare.

    You'll get not one, but TWO warnings for code that is totally correct, and
    that it would make _no_ sense in writing any other way.

    In short, -Wsign-compare (at least with a _lot_ of gcc versions) warns for
    totally sane and reasonable code - for code that exists all over the
    kernel. The above snippet is in fact directly from the kernel, go look and
    see for yourself.

    In short, -Wsign-compare is totally useless. The warnings are mostly _so_
    bogus that nobody has the energy to even try to figure out which of them
    might actually be worthwhile.

    Face it, you don't know what you're talking about.

    Linus

    -
    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 13:01    [W:3.376 / U:0.288 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site