aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-06-04 19:12:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:54:20 -0400
commitf5ef95b12eb03ae4b3994cdb035612e127b630b9 (patch)
tree1fe1265d5b6570ba3df3b39b8f2c3a74121e6abb /scripts
parent2ac73b4f685e699ccdfa6855e826df846999d577 (diff)
checkpatch: warn on #defines ending in semicolon
Using a #define ending in a semicolon is poor style and can lead to unexpected code paths being executed. Warn on uses of these #define types: #define foo[(...)] bar; #define foo[(...)] \ bar; Based on a patch from Borislav Petkov. Signed-off-by: Joe Perches <joe@perches.com> Cc: Borislav Petkov <bp@suse.de> 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.pl11
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bb4c8428f333..e7ff52a39ec9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3821,6 +3821,17 @@ sub process {
3821 WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", 3821 WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON",
3822 "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); 3822 "do {} while (0) macros should not be semicolon terminated\n" . "$herectx");
3823 } 3823 }
3824 } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) {
3825 $ctx =~ s/\n*$//;
3826 my $cnt = statement_rawlines($ctx);
3827 my $herectx = $here . "\n";
3828
3829 for (my $n = 0; $n < $cnt; $n++) {
3830 $herectx .= raw_line($linenr, $n) . "\n";
3831 }
3832
3833 WARN("TRAILING_SEMICOLON",
3834 "macros should not use a trailing semicolon\n" . "$herectx");
3824 } 3835 }
3825 } 3836 }
3826 3837