2022-02-04 17:38:58

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH V5 1/3] platform/x86: Add Intel Software Defined Silicon driver

On Fri, 2022-02-04 at 05:23 -0800, David E. Box wrote:
> On Fri, 2022-02-04 at 02:14 -0800, Joe Perches wrote:
> > On Thu, 2022-02-03 at 21:30 -0800, David E. Box wrote:
[]
> > > - In binary attribute handlers where ret is only used for errors,
> > > replace,
> > > return (ret < 0) ? ret : size;
> > > with,
> > > return ret ?: size;
> >
> > I think this style overly tricky.
> >
> > Why not the canonical:
> >
> > if (ret < 0)
> > return ret;
> >
> > return size;
>
> I can see not using the 2 parameter shortcut of the ternary operator, but the
> regular 3 parameter expression is easy to read for simple operations.

The issue to me is it combines an error test and error return
with the common return.

it's also being used and avoided / naked with the similar

return min(ret, size);

https://lore.kernel.org/lkml/[email protected]/T/



2022-02-04 22:12:49

by David E. Box

[permalink] [raw]
Subject: Re: [PATCH V5 1/3] platform/x86: Add Intel Software Defined Silicon driver

On Fri, 2022-02-04 at 06:01 -0800, Joe Perches wrote:
> On Fri, 2022-02-04 at 05:23 -0800, David E. Box wrote:
> > On Fri, 2022-02-04 at 02:14 -0800, Joe Perches wrote:
> > > On Thu, 2022-02-03 at 21:30 -0800, David E. Box wrote:
> []
> > > > - In binary attribute handlers where ret is only used for errors,
> > > > replace,
> > > > return (ret < 0) ? ret : size;
> > > > with,
> > > > return ret ?: size;
> > >
> > > I think this style overly tricky.
> > >
> > > Why not the canonical:
> > >
> > > if (ret < 0)
> > > return ret;
> > >
> > > return size;
> >
> > I can see not using the 2 parameter shortcut of the ternary operator, but
> > the
> > regular 3 parameter expression is easy to read for simple operations.
>
> The issue to me is it combines an error test and error return
> with the common return.

Ah, okay.

>
> it's also being used and avoided / naked with the similar
>
> return min(ret, size);
>
> https://lore.kernel.org/lkml/[email protected]/T/

Thanks.