* checkpatch: exclude drivers/staging from if with unnecessary parentheses test
@ 2018-01-11 20:53 Joe Perches
2018-01-11 23:03 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2018-01-11 20:53 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML, Greg KH
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.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d2464058ab5d..3a7499de2c2d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4526,7 +4526,9 @@ sub process {
}
# check for unnecessary parentheses around comparisons in if uses
- if ($^V && $^V ge 5.10.0 && defined($stat) &&
+# when !drivers/staging or command-line uses --strict
+ if (($realfile !~ m@^(?:drivers/staging/)@ || $check_orig) &&
+ $^V && $^V ge 5.10.0 && defined($stat) &&
$stat =~ /(^.\s*if\s*($balanced_parens))/) {
my $if_stat = $1;
my $test = substr($2, 1, -1);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: checkpatch: exclude drivers/staging from if with unnecessary parentheses test
2018-01-11 20:53 checkpatch: exclude drivers/staging from if with unnecessary parentheses test Joe Perches
@ 2018-01-11 23:03 ` Andrew Morton
2018-01-12 1:17 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2018-01-11 23:03 UTC (permalink / raw)
To: Joe Perches; +Cc: LKML, Greg KH
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?
Also, an example of code which has an "if with unnecessary parentheses"
would help others understand the decision.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: checkpatch: exclude drivers/staging from if with unnecessary parentheses test
2018-01-11 23:03 ` Andrew Morton
@ 2018-01-12 1:17 ` Joe Perches
2018-01-12 1:40 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2018-01-12 1:17 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML, Greg KH
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: checkpatch: exclude drivers/staging from if with unnecessary parentheses test
2018-01-12 1:17 ` Joe Perches
@ 2018-01-12 1:40 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2018-01-12 1:40 UTC (permalink / raw)
To: Joe Perches; +Cc: LKML, Greg KH
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 ;)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-12 1:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-11 20:53 checkpatch: exclude drivers/staging from if with unnecessary parentheses test Joe Perches
2018-01-11 23:03 ` Andrew Morton
2018-01-12 1:17 ` Joe Perches
2018-01-12 1:40 ` Andrew Morton
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®