2.4.10-pre9 min/max raises "const" warnings

Alexander Stohr
2001-09-14T17:57:22Z

try this one:

int a, b, c, d;
d = min( a, min( b, c ));

and you will see a gnu c warning about multiple const qualifiers.
(this might depend on the warning level you drive.)

fix it with this code:

#define min(x,y) ({ \

const typeof(x) _x = (x); \

const typeof(y) _y = (y); \

(void) (&_x == &_y); \

(_x < _y) ? (typeof(x)) _x : (typeof(y)) _y; })

simply the last line has changed towards linux kernel patch-2.4.10-pre9 from
ftp.
the same change should apply for the max() macro.

i am yet not sure if the used "? :" operator set does qualify as
a left-value. maybe this could be another important reason why
return types here should stay identical to input types.

regards AlexS.

PS: i am not subscribed to this list.