lkml.org 
[lkml]   [2001]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [IDEA+RFC] Possible solution for min()/max() war
--- Alexander Viro <viro@math.psu.edu> 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):
> >
> > #ifdef CONFIG_ALLOW_COMPAT_MINMAX
> > #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


=====
Brad Chapman

Permanent e-mail: kakadu_croc@yahoo.com
Current e-mail: kakadu@adelphia.net
Alternate e-mail: kakadu@netscape.net

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
-
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 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