lkml.org 
[lkml]   [2007]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC][PATCH] fix abs() macro to work with types wider than int
    > > Can there even be any reason beyond unnecessary pedantics to have [l[l]]abs?
    >
    > See Paragraph 1 above. We do lots of functions in a manner that is
    > like C (or libc) so that we don't confuse developers.

    I have the perfect solution that includes compatibility while avoiding
    stupidity.

    Macro "abs" which evaluates its argument once and uses typeof().

    #define labs(n) abs(n)
    #define llabs(n) labs(n)

    Leave that in the kernel for a year or two. At the end of that time, grep
    the kernel to show that only two silly people actually use them. Change
    those, and remove the aliases. Sense restored.

    As far as I'm concerned, the only reason those functions exist like that
    is because standard C doesn't support function overloading and doesn't
    want to promote every argument to the biggest width and -also- can't
    define it as a macro because there's no typeof() in standard C. So since
    we do have it...

    ...and why do we want people hacking the kernel who get confused by a
    single "abs" function? Isn't that quite a lot like saying "Do not use
    hairdryer while sleeping."?
    -
    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: 2007-04-26 01:45    [W:0.061 / U:117.912 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site