[lkml]   [2001]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [IDEA+RFC] Possible solution for min()/max() war
--- Alexander Viro <> wrote:
> On Fri, 24 Aug 2001, Brad Chapman wrote:
> > OK. The existing API is wrong and the new min()/max() macros are the
> > right way to properly compare values. However, we could always add a config
> > option to enable a compatibility macro, which would use typeof() on one of the
> > two variables and then call the real min()/max(). Something like this (just an
> > example):
> >
> > #define proper_min(t, a, b) ((t)(a) < (t)(b) ? (a) : (b))
> > #define proper_max(t, a, b) ((t)(a) > (t)(b) ? (a) : (b))
> > #define min(a, b) proper_min(typeof(a), a, b)
> > #define max(a, b) proper_max(typeof(a), a, b)
> _THAT_ _IS_ _WRONG_. Who the fuck said that we always want type of _first_
> argument? Mind you, IMNSHO Dave had been on a seriously bad trip when he
> had added that "type" argument - separate names would be cleaner. And yes,
> it'd be better in prepatch instead of 2.4.9-final.

I never said we had to use the _first_ argument. We could always do
the _second_. Or we could scrap the whole idea of compatibility with any of the old,
"broken" type-unsafe code and make everybody use the new macros. Period.

> However, no matter which variant you pick, old code with min/max
> was broken. Unless you are carefully giving right types (preferanly -
> with casts) it works only by accidents (if it works at all).
> "Compatibility option" is exactly the worst thing in such cases.
> It's either changing the whole codebase or not bothering at all.

Ack. Seems like the best way to fix this is to either make everybody
use the new macros, or wait for Linus to show up ;-)


Brad Chapman

Permanent e-mail:
Current e-mail:
Alternate e-mail:

Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
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: 2005-03-22 12:58    [W:0.137 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site