lkml.org 
[lkml]   [2001]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [IDEA+RFC] Possible solution for min()/max() war -- I like this
Herbert Rosmanith wrote:

> #define type_min(type,x,y) \
> ({ type __x = (x), __y = (y); __x < __y ? __x: __y; })
> #define type_max(type,x,y) \
> ({ type __x = (x), __y = (y); __x > __y ? __x: __y; })
>
> #define min(x,y) type_min(typeof(x),x,y)
> #define max(x,y) type_max(typeof(x),x,y)
>
> no _implicit_ cast and ...
>
> > One of the arguments gets changed invisibly, and that is what kernel
> > developers are so upset about. You don't really know which one without
> > thinking hard about it, and that is a source of many hard-to-find bugs.
>
> ... joy, we would even know which one.

I think this makes a lot of sense. The explicit version could be preferred, but
for the implicit version we at least know that what type will be used for it and
it won't immediately break things that are still using the old-style min/max.


--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: cfriesen@nortelnetworks.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 13:01    [W:0.053 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site