2.4.10-pre9 min/max raises "const" warnings

Alexander Stohr (AlexanderS@ati.com)
Fri, 14 Sep 2001 19:55:35 +0200


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.

-
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/