Re: [PATCH 1/4] kernel.h: add find_closest() macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx> 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

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors




[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux