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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux