In kernel.h min is defined as:
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
I don’t understand what the line (void) (&_min1 == &_min2); does. Is it some kind of type checking or something?
The statement
is a guaranteed “no-op”. So the only reason it’s there is for its side effects.
But the statement has no side effects!
However: it forces the compiler to issue a diagnostic when the types of
xandyare not compatible.Note that testing with
_min1 == _min2would implicitly convert one of the values to the other type.So, that is what it does. It validates, at compile time, that the types of
xandyare compatible.