public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 2.4.10-pre9 min/max raises "const" warnings
@ 2001-09-14 17:55 Alexander Stohr
  2001-09-14 18:55 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Stohr @ 2001-09-14 17:55 UTC (permalink / raw)
  To: linux-kernel

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-09-14 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-14 17:55 2.4.10-pre9 min/max raises "const" warnings Alexander Stohr
2001-09-14 18:55 ` Andreas Schwab
2001-09-14 22:55   ` J . A . Magallon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox