| Date | Thu, 3 Aug 2023 21:00:35 +0800 | Subject | Re: [PATCH v6 01/38] minmax: Add in_range() macro | From | Phi Nguyen <> |
| |
On 8/2/2023 11:13 PM, Matthew Wilcox (Oracle) wrote: > diff --git a/include/linux/minmax.h b/include/linux/minmax.h > index 798c6963909f..83aebc244cba 100644 > --- a/include/linux/minmax.h > +++ b/include/linux/minmax.h > @@ -3,6 +3,7 @@ > #define _LINUX_MINMAX_H > > #include <linux/const.h> > +#include <linux/types.h> > > /* > * min()/max()/clamp() macros must accomplish three things: > @@ -222,6 +223,32 @@ > */ > #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) > > +static inline bool in_range64(u64 val, u64 start, u64 len) > +{ > + return (val - start) < len; > +} > + > +static inline bool in_range32(u32 val, u32 start, u32 len) > +{ > + return (val - start) < len; > +} > +
I think these two functions return wrong result if val is smaller than start and len is big enough.
|