linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Melissa Wen <melissa.srw@gmail.com>,
	devel@driverdev.osuosl.org, Lars-Peter Clausen <lars@metafoo.de>,
	Stefan Popa <stefan.popa@analog.com>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	linux-iio@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Barry Song <21cnbao@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Hartmut Knaack <knaack.h@gmx.de>
Subject: Re: [PATCH] staging: iio: ad7150: use ternary operating to ensure 0/1 value
Date: Sat, 22 Jun 2019 11:58:58 +0100	[thread overview]
Message-ID: <20190622115858.21ceef2d@archlinux> (raw)
In-Reply-To: <20190617084033.GG28859@kadam>

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
> 


      reply	other threads:[~2019-06-22 10:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 16:50 [PATCH] staging: iio: ad7150: use ternary operating to ensure 0/1 value Melissa Wen
2019-06-16 10:15 ` Jonathan Cameron
2019-06-17  8:40   ` Dan Carpenter
2019-06-22 10:58     ` Jonathan Cameron [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20190622115858.21ceef2d@archlinux \
    --to=jic23@kernel.org \
    --cc=21cnbao@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-usp@googlegroups.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=melissa.srw@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=stefan.popa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).