Re: [RFC][PATCH] fix abs() macro to work with types wider than int

From: John Anthony Kazos Jr.
Date: Wed Apr 25 2007 - 19:42:51 EST


> > 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/