mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Greg KH <gregkh@linuxfoundation.org>
Subject: Re: checkpatch: exclude drivers/staging from if with unnecessary parentheses test
Date: Thu, 11 Jan 2018 17:40:15 -0800	[thread overview]
Message-ID: <20180111174015.3de3dcd03730cba164d0a97b@linux-foundation.org> (raw)
In-Reply-To: <1515719873.9619.179.camel@perches.com>

On Thu, 11 Jan 2018 17:17:53 -0800 Joe Perches <joe@perches.com> wrote:

> On Thu, 2018-01-11 at 15:03 -0800, Andrew Morton wrote:
> > On Thu, 11 Jan 2018 12:53:54 -0800 Joe Perches <joe@perches.com> wrote:
> > 
> > > Greg KH doesn't like this test so exclude the staging directory
> > > from the implied --strict only test unless --strict is actually
> > > used on the command-line.
> > > 
> > 
> > "doesn't like" is rather vague.  What is the objection, specifically?
> 
> Unnecessary parentheses sometimes make code
> easier to read for those that don't know C
> very well.  i.e.: Greg and maybe others too.
> 
> > Also, an example of code which has an "if with unnecessary parentheses"
> > would help others understand the decision.
> 
> 	if ((foo == bar) &&
> 	    (baz != qux))
> 
> where the parentheses around the comparisons are
> generically unnecessary as the && is a much higher
> precedence than the comparisons.

OK, agree.  I too don't like to be doubtfully staring at something
trying to remember the precedence rules.

Within limits.  There are of course cases where the parenthesization is
silly (who doesn't know that * is higher than +?).  But such
silliness-detection is probably beyond checkpatch ;)

      reply	other threads:[~2018-01-12  1:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 20:53 Joe Perches
2018-01-11 23:03 ` Andrew Morton
2018-01-12  1:17   ` Joe Perches
2018-01-12  1:40     ` Andrew Morton [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=20180111174015.3de3dcd03730cba164d0a97b@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®