[KJ] [PATCH] MIN/MAX cleanup
Amol Lad
amol at verismonetworks.com
Fri Sep 8 00:47:15 PDT 2006
include/linux/kernel.h:
#define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
The casts are required as these macros do very strict type checking (see
&_x == &_y compare at line 4).
Compiler throws up a warning if min/max are passed arguments of
different types..
On Fri, 2006-09-08 at 13:19, Henk Vergonet wrote:
> On Thu, Sep 07, 2006 at 05:52:21PM +0530, Amol Lad wrote:
> > Cleanups done to use min/max macros from kernel.h. Handcrafted MIN/MAX
> > macros in some drivers are changed to use macros from kernel.h
> >
> > + clength = MIN((word)(270-length),(word) (X[i].PLength-this->XOffset));
>
> What is the rationale behind all those type casts?
>
> Should we now also write:
> if(uint > (unsigned int)300) {
> instead of
> if(uint > 300) {
>
> Can someone explain this?
>
> - rme
More information about the Kernel-janitors
mailing list