lkml.org 
[lkml]   [2019]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: iio: ad7150: use ternary operating to ensure 0/1 value
On Mon, 17 Jun 2019 11:40:34 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> On Sun, Jun 16, 2019 at 11:15:16AM +0100, Jonathan Cameron wrote:
> > On Fri, 14 Jun 2019 13:50:59 -0300
> > Melissa Wen <melissa.srw@gmail.com> wrote:
> >
> > > Remove idiom and use ternary operator for consistently trigger 0/1 value
> > > on variable declaration.
> > >
> > > Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
> > Hi Melissa,
> >
> > In general I would consider this unnecessary churn as, whilst
> > it's no longer a favoured idiom, it is extremely common in the
> > kernel.
>
> It's still my favourite... Why wouldn't people like it? It feels like
> last week I just saw someone send a bunch of:
>
> - foo = (bar == baz) ? 1 : 0;
> + foo = (bar == baz);
>
> patches and I thought it was an improvement at the time...

That one is nice enough, it's the !! that Linus came out fairly
strongly against though not sure I can find the particular email.
That one is a fairly kernel specific idiom that I'll be honest I've
rarely seen elsewhere ;) I remember wincing at the thread
on this as it was an idiom I personally rather liked.

In cases where it doesn't matter because foo doesn't need to 1 or
0 then what you have is nice and clean.

I can't say it's one I care that much about, but I am happy if code
that happens to be under cleanup anyway has this little bit made
the 'preferred style'. There is something to said for consistency.

Jonathan


>
> regards,
> dan carpenter
>

\
 
 \ /
  Last update: 2019-06-22 13:00    [W:0.080 / U:0.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site