aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-08-21 19:15:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-08-21 19:45:02 -0400
commitac8e97f8a742828daa1d9de37f6e635888f8d71e (patch)
treed2eae9170d79c302d99c0d7a27da134060fde69e /scripts
parenteb48c071464757414538c68a6033c8f8c15196f8 (diff)
checkpatch: add control statement test to SINGLE_STATEMENT_DO_WHILE_MACRO
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 <joe@perches.com> Acked-by: Andy Whitcroft <apw@canonical.com> Tested-by: Franz Schrober <franzschrober@yahoo.de> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 913d6bdfdda3..ca05ba217f5f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3016,7 +3016,8 @@ sub process {
3016 $herectx .= raw_line($linenr, $n) . "\n"; 3016 $herectx .= raw_line($linenr, $n) . "\n";
3017 } 3017 }
3018 3018
3019 if (($stmts =~ tr/;/;/) == 1) { 3019 if (($stmts =~ tr/;/;/) == 1 &&
3020 $stmts !~ /^\s*(if|while|for|switch)\b/) {
3020 WARN("SINGLE_STATEMENT_DO_WHILE_MACRO", 3021 WARN("SINGLE_STATEMENT_DO_WHILE_MACRO",
3021 "Single statement macros should not use a do {} while (0) loop\n" . "$herectx"); 3022 "Single statement macros should not use a do {} while (0) loop\n" . "$herectx");
3022 } 3023 }