Re: [PATCH v2 1/2] minmax: Add in_range_inclusive() for inclusive range checks

From: Guru Das Srinagesh

Date: Mon Aug 31 2026 - 17:41:41 EST


On Sun, Aug 16, 2026 at 10:34:59PM +0100, Matthew Wilcox wrote:
> On Sun, Aug 16, 2026 at 12:26:20PM -0700, Guru Das Srinagesh wrote:
> > +++ b/include/linux/minmax.h
> > @@ -299,6 +299,25 @@ static inline bool in_range32(u32 val, u32 start, u32 len)
> > ((sizeof(start) | sizeof(len) | sizeof(val)) <= sizeof(u32) ? \
> > in_range32(val, start, len) : in_range64(val, start, len))
> >
> > +#define __in_range_inclusive(val, start, end, uval, ustart, uend) ({ \
> > + typeof(val) uval = (val); \
> > + typeof(start) ustart = (start); \
> > + typeof(end) uend = (end); \
> > + uval >= ustart && uval <= uend; \
>
> By convention, 'end' is used for exclusive ranges while 'max' is used
> for inclusive ranges.

Changed to use 'min' and 'max' instead.

> Also, this seems completely wrong. How do you think this is unsigned
> comparisons? I think you'd do better to follow the example of
> in_range() much more closely.

Done - v3 now follows in_range() closely.