From: Andrew Morton <akpm@linux-foundation.org>
To: Alexandru Ardelean <aardelean@baylibre.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
jic23@kernel.org, bartosz.golaszewski@linaro.org,
gregkh@linuxfoundation.org
Subject: Re: [PATCH v2 1/2] util_macros.h: fix/rework find_closest() macros
Date: Wed, 6 Nov 2024 12:08:48 -0800 [thread overview]
Message-ID: <20241106120848.63b6665af42264a70bba1621@linux-foundation.org> (raw)
In-Reply-To: <CA+GgBR-a050NUMB4Z=Q1UhqjAcKRVVw4k+S9uBZp6iRGqHkB6A@mail.gmail.com>
On Wed, 6 Nov 2024 16:03:36 +0200 Alexandru Ardelean <aardelean@baylibre.com> wrote:
> On Wed, Nov 6, 2024 at 1:08 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> > Can we fix both issues by just giving up on the macro approach and
> > reimplement them in out-of-line C code? All the sites I looked at are
> > using 32-bit quantities - a mix of signed and unsigned.
> >
>
> Converting this to a static-inline was my other thought, rather than
> keeping the macros.
Non-inline, I think. It's big.
> But I'm not sure where to draw the line between too much rework vs a bug-fix.
> Just fixing the bug was done in V1 of this patch, but then the kunit
> exposed a bunch more.
Sure, just the minimum for a bugfix.
> > It's separate from this bugfix of course, but would it be feasible for
> > someone to go switch all callers to use u32's then reimplement these in
> > lib/find_closest.c?
> >
>
> That would work.
> How would a rework be preferred?
> As a continuation to this patchset? Or a V3 to this patchset?
A new and separate patchset. A low-priority cleanup from whoever has
the time and motivation ;)
> But, moving forward: what would some preferences be?
> - have variants of find_closest() for unsigned/signed arrays? (
> find_closest_u32() or find_closest_i32() ?)
> - AFAICT so far, there aren't any values in the arrays that get
> close to INT32_MAX, so int32 may work for now
> - maybe later some 64-bit variants could be added if needed
> - should the variables X, mid, left & right be the same signedness as the array
>
> The only preference (towards which I'm leaning) is just making sure
> that X (and friends) are signed.
Yes, I guess int32 would be best. I agree that unsigned values greater
than INT_MAX are unlikely.
I suggest a series of patches which convert individual callers to int32
and the final patch introduces lib/find_closest.c.
prev parent reply other threads:[~2024-11-06 20:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 14:54 [PATCH v2 1/2] util_macros.h: fix/rework find_closest() macros Alexandru Ardelean
2024-11-05 14:54 ` [PATCH v2 2/2] lib: util_macros_kunit: add kunit test for util_macros.h Alexandru Ardelean
2024-11-05 23:08 ` [PATCH v2 1/2] util_macros.h: fix/rework find_closest() macros Andrew Morton
2024-11-06 14:03 ` Alexandru Ardelean
2024-11-06 20:08 ` Andrew Morton [this message]
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=20241106120848.63b6665af42264a70bba1621@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aardelean@baylibre.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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