> --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -636,6 +636,12 @@ static inline void ftrace_dump(enum ftrace_dump_mode > oops_dump_mode) { } (void) (&_max1 == &_max2); \ > _max1 > _max2 ? _max1 : _max2; }) > > +/* > + * Returns the minimum that is _not_ zero, unless both are zero. > + */ > +#define min_not_zero(__x, __y) ({ \ > + __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) > + > /** > * clamp - return a value clamped to a given range with strict > typechecking * @val: current value This will evaluate the value of __x and __y multiple times. Something like this should be better (untested): define min_not_zero(__x, __y) ({ \ typeof(__x) _minz1 = (__x); \ typeof(__y) _minz2 = (__y); \ _minz1 == 0 ? _minz2 : ((_minz2 == 0) ? _minz1 : min(_minz1, _minz2)); }) Eike
Attachment:
signature.asc
Description: This is a digitally signed message part.