LKML Archive on
help / color / mirror / Atom feed
From: Phil Pokorny <>
To: Bartosz Golaszewski <>
Cc: LKML <>,
	lm-sensors <>
Subject: Re: [lm-sensors] [PATCH 1/4] kernel.h: add find_closest() macro
Date: Tue, 24 Feb 2015 12:33:06 -0800	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Feb 24, 2015 at 9:42 AM, Bartosz Golaszewski
<> 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.

Philip Pokorny, RHCE
Chief Technology Officer

Changing the world through technical innovation

  reply	other threads:[~2015-02-24 20:33 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   ` Phil Pokorny [this message]
2015-02-24 20:51     ` [lm-sensors] " Guenter Roeck
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:

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

  git send-email \
    --in-reply-to='' \ \ \ \ \
    --subject='Re: [lm-sensors] [PATCH 1/4] kernel.h: add find_closest() macro' \

* 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).