lkml.org 
[lkml]   [2018]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: checkpatch: exclude drivers/staging from if with unnecessary parentheses test
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 ;)


\
 
 \ /
  Last update: 2018-01-14 23:25    [W:0.054 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site