mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Guru Das Srinagesh <linux@gurudas.dev>
Cc: "Alex Lanzano" <lanzano.alex@gmail.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Gustavo Silva" <gustavograzs@gmail.com>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 1/2] minmax: Add in_range_inclusive() for inclusive range checks
Date: Sun, 16 Aug 2026 22:34:59 +0100	[thread overview]
Message-ID: <aoItA_ktl04qmhEb@casper.infradead.org> (raw)
In-Reply-To: <20260816-minmax-in-range-incl-v2-1-766f737dd6bf@gurudas.dev>

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.

  reply	other threads:[~2026-08-16 21:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 19:26 [PATCH v2 0/2] Introduce in_range_incl() inclusive range check macro Guru Das Srinagesh
2026-08-16 19:26 ` [PATCH v2 1/2] minmax: Add in_range_inclusive() for inclusive range checks Guru Das Srinagesh
2026-08-16 21:34   ` Matthew Wilcox [this message]
2026-08-31 16:29     ` Guru Das Srinagesh
2026-08-17  8:06   ` Andy Shevchenko
2026-08-31 16:33     ` Guru Das Srinagesh
2026-08-16 19:26 ` [PATCH v2 2/2] iio: imu: bmi270: Use in_range_inclusive() in bmi270_write_event_value() Guru Das Srinagesh
2026-08-17  3:00   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aoItA_ktl04qmhEb@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gustavograzs@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lanzano.alex@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@gurudas.dev \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®