scripts/checkpatch.pl: add check for `while` and `for`
RFC PATCH v2 1/1 scripts/checkpatch.pl: add check for `while` and `for`
Add check for while and for statements, which condition has more than one line.
The former checkpatch.pl can check if statement, which condition has more than one line, whether block misses brace round, like this:
'''
if (cond1 ||
cond2)
statement;'''
But it doesn't do the same check for for and while statements.
--- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
@@ -2353,7 +2353,8 @@ sub process { } # check for missing bracing round if etc - if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) { + if ($line =~ /(^.*)\b(for|while|if)\b/ && + $line !~ /\#\s*(for|while|if)/) { my ($level, $endln, @chunks) = ctx_statement_full($linenr, $realcnt, 1); if ($dbg_adv_apw) {
Signature · 1 line
2.7.4
scripts/checkpatch.pl sub process { · line 2355
Quoted 8 lines · Su Hang
scripts/checkpatch.pl +0
-0@@ -2353,7 +2353,8 @@ sub process { } # check for missing bracing round if etc
Please fix the pre-existing typo in the comment:
s/round/around/
scripts/checkpatch.pl sub process { · line 2357
Quoted 3 lines
scripts/checkpatch.pl +2
-1- if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) { + if ($line =~ /(^.*)\b(for|while|if)\b/ && + $line !~ /\#\s*(for|while|if)/) {
Please use (?:...) like most other cases in checkpatch.pl. Perl automatically assigns groups to $1, $2, etc with (...). Using (?:...) is preferred since it's faster and free of this side-effect.
Quoted 8 lines · Stefan Hajnoczi
Quoted 7 lines · Su Hang
scripts/checkpatch.pl +0
-0@@ -2353,7 +2353,8 @@ sub process { }
Quoted 5 lines
scripts/checkpatch.pl sub process { · line 2355
Quoted 1 line
scripts/checkpatch.pl +0
-0# check for missing bracing round if etcPlease fix the pre-existing typo in the comment:
s/round/around/
That's not really a typo IMHO -- both 'round' and 'around' seem fine to me here. (The OED entry for 'around' notes "There is variation with 'round' adv. and prep. in many of the senses below; in general 'around' is less usual in British usage", so some of this is US-vs-UK usage or personal idiolect.)
thanks
-- PMM
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Stefan Hajnoczi
scripts/checkpatch.pl sub process { · line 2355
Quoted 8 lines · Su Hang
scripts/checkpatch.pl +0
-0@@ -2353,7 +2353,8 @@ sub process { } # check for missing bracing round if etcPlease fix the pre-existing typo in the comment:
Quoted 7 lines
Quoted 1 line
s/round/around/
That's not really a typo IMHO -- both 'round' and 'around' seem fine to me here. (The OED entry for 'around' notes "There is variation with 'round' adv. and prep. in many of the senses below; in general 'around' is less usual in British usage", so some of this is US-vs-UK usage or personal idiolect.)
Thanks! I hear British people use it frequently but thought it was a colloquialism that isn't used in written form, innit? :) I stand corrected.
Stefan