Re: [PATCH v2 1/2] minmax: Add in_range_inclusive() for inclusive range checks
From: Matthew Wilcox
Date: Sun Aug 16 2026 - 17:35:28 EST
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.
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.
ie this is AI slop. Please learn how C works, and write the code
yourself. Use the AI to check your work, not do it for you, because it
leads to people wasting their time trying to manipulate you into
manipulating your AI to produce good code. That's not a good thing.