Re: [PATCH rdma-core 2/5] utils: Create utils directory to put all common code and move min/max into it

Jason Gunthorpe
2016-09-26T17:20:06Z

On Sun, Sep 25, 2016 at 09:50:04AM +0300, Leon Romanovsky wrote:

> -#ifndef min
> -#define min(a, b) \
> - ({ typeof(a) _a = (a); \
> - typeof(b) _b = (b); \
> - _a < _b ? _a : _b; })
> -#endif
> -
> -#ifndef max
> -#define max(a, b) \
> - ({ typeof(a) _a = (a); \
> - typeof(b) _b = (b); \
> - _a > _b ? _a : _b; })
> -#endif

I'm not excited to replace the safer min above with the less safe min
below, that could actually break something.

> +/*
> + * This include contains all common mathematical functions
> + */
> +#ifndef min
> +#define min(a, b) (((a) < (b)) ? (a) : (b))
> +#endif
> +
> +#ifndef max
> +#define max(a, b) (((a) > (b)) ? (a) : (b))
> +#endif
> +#endif /* _RDMA_MATH_H_ */

Jason