LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Phil Pokorny <ppokorny@penguincomputing.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
LKML <linux-kernel@vger.kernel.org>,
lm-sensors <lm-sensors@lm-sensors.org>
Subject: Re: [lm-sensors] [PATCH 1/4] kernel.h: add find_closest() macro
Date: Tue, 24 Feb 2015 12:51:25 -0800 [thread overview]
Message-ID: <20150224205125.GB18025@roeck-us.net> (raw)
In-Reply-To: <CAAek22F3JzWRVqwf=QdaoowjTSkfHAiUP6orpHpcdt_gicaT=A@mail.gmail.com>
On Tue, Feb 24, 2015 at 12:33:06PM -0800, Phil Pokorny wrote:
> On Tue, Feb 24, 2015 at 9:42 AM, Bartosz Golaszewski
> <bgolaszewski@baylibre.com> wrote:
> >
> > Searching for the member of an array closest to 'x' is
> > duplicated in several places.
> >
> > Add two macros that implement this algorithm for arrays
> > sorted both in ascending and descending order.
>
> I don't see the point here. You're not saving any code because your
> macros create functions at each invocation site. And your macro is
> more complicated than the code it replaces because it has all the
> syntactic cruft to make it adaptable to the different datatypes and
> sort orders.
>
> Certainly it is easy to make an off by one mistake in a loop like this
> so there might be some small value there, but I'm not sure the
> complication is worth that savings for the small number of use points.
> Particularly because you're not saving any code.
>
I think the lm85 conversion actually introduces a bug with such an
off-by-one mistake. And if it doesn't, there is still a unexplained
and not easy to understand '-1' in one of the calls to find_closest().
So the question is if the new code really improves the situation in that
respect.
Guenter
next prev parent reply other threads:[~2015-02-24 20:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 17:42 [PATCH 0/4] " Bartosz Golaszewski
2015-02-24 17:42 ` [PATCH 1/4] kernel.h: add " Bartosz Golaszewski
2015-02-24 20:33 ` [lm-sensors] " Phil Pokorny
2015-02-24 20:51 ` Guenter Roeck [this message]
2015-02-25 10:59 ` Bartosz Golaszewski
2015-02-26 0:13 ` Guenter Roeck
2015-02-24 17:42 ` [PATCH 2/4] hwmon: (ina2xx) replace ina226_avg_bits() with find_closest() Bartosz Golaszewski
2015-02-24 17:42 ` [PATCH 4/4] hwmon: (w83795) use find_closest_desc() in pwm_freq_to_reg() Bartosz Golaszewski
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=20150224205125.GB18025@roeck-us.net \
--to=linux@roeck-us.net \
--cc=bgolaszewski@baylibre.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=ppokorny@penguincomputing.com \
--subject='Re: [lm-sensors] [PATCH 1/4] kernel.h: add find_closest() macro' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).