projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eb48c07
)
checkpatch: add control statement test to SINGLE_STATEMENT_DO_WHILE_MACRO
author
Joe Perches
<
[email protected]
>
Tue, 21 Aug 2012 23:15:53 +0000
(16:15 -0700)
committer
Linus Torvalds
<
[email protected]
>
Tue, 21 Aug 2012 23:45:02 +0000
(16:45 -0700)
Commit
b13edf7ff2dd
("checkpatch: add checks for do {} while (0) macro
misuses") added a test that is overly simplistic for single statement
macros.
Macros that start with control tests should be enclosed in a do {} while
(0) loop.
Add the necessary control tests to the check.
Signed-off-by: Joe Perches <
[email protected]
>
Acked-by: Andy Whitcroft <
[email protected]
>
Tested-by: Franz Schrober <
[email protected]
>
Cc: Stephen Rothwell <
[email protected]
>
Signed-off-by: Andrew Morton <
[email protected]
>
Signed-off-by: Linus Torvalds <
[email protected]
>
scripts/checkpatch.pl
patch
|
blob
|
history
diff --git
a/scripts/checkpatch.pl
b/scripts/checkpatch.pl
index 913d6bdfdda3ecb44f521af79980019d5a531399..ca05ba217f5fd4038bcc511adff8a5b95823fb3e 100755
(executable)
--- a/
scripts/checkpatch.pl
+++ b/
scripts/checkpatch.pl
@@
-3016,7
+3016,8
@@
sub process {
$herectx .= raw_line($linenr, $n) . "\n";
}
- if (($stmts =~ tr/;/;/) == 1) {
+ if (($stmts =~ tr/;/;/) == 1 &&
+ $stmts !~ /^\s*(if|while|for|switch)\b/) {
WARN("SINGLE_STATEMENT_DO_WHILE_MACRO",
"Single statement macros should not use a do {} while (0) loop\n" . "$herectx");
}