Re: [PATCH v2] minmax: clamp more efficiently by avoiding extra comparison

From: Jason A. Donenfeld
Date: Fri Sep 23 2022 - 12:55:07 EST


On Fri, Sep 23, 2022 at 6:53 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Fri, Sep 23, 2022 at 09:41:19AM -0700, Kees Cook wrote:
> > On Fri, Sep 23, 2022 at 05:40:01PM +0200, Jason A. Donenfeld wrote:
>
> ...
>
> > > + __clamp(val, lo, hi), \
> > > + __clamp_once(val, lo, hi, __UNIQUE_ID(__val), __UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); })
> >
> > *complaint about line being >100 characters, but I don't really care* If
> > anyone is really bothered, this looks fine, too:
> >
> > __clamp_once(val, lo, hi, \
> > __UNIQUE_ID(__val), __UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); })
>
> Actually }) should occupy a separate line and it would be nice to have it for ({.

That's what I would have done, except another macro in there didn't do
it like that, so I tried to copy the existing form.

Kees - do you want to touch up stylistic things as you see fit upon
commit, or do you want a v3 from me?

Jason