diff options
author | Joe Perches <joe@perches.com> | 2014-06-04 19:12:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:19 -0400 |
commit | 3f7bac031c6ba61c89b06b279f74a25309da1625 (patch) | |
tree | c7103eb6368007eda148010c4390ddf79ba8f72c /scripts | |
parent | 185d566bcd0a8e83fe762b3bbef1d58347b9a034 (diff) |
checkpatch: always warn on missing blank line after variable declaration block
Make the test system wide, modify the message too.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 62d005e06031..f2ef63a2e8d4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -397,6 +397,11 @@ foreach my $entry (@mode_permission_funcs) { | |||
397 | $mode_perms_search .= $entry->[0]; | 397 | $mode_perms_search .= $entry->[0]; |
398 | } | 398 | } |
399 | 399 | ||
400 | our $declaration_macros = qr{(?x: | ||
401 | (?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(| | ||
402 | (?:$Storage\s+)?LIST_HEAD\s*\( | ||
403 | )}; | ||
404 | |||
400 | our $allowed_asm_includes = qr{(?x: | 405 | our $allowed_asm_includes = qr{(?x: |
401 | irq| | 406 | irq| |
402 | memory | 407 | memory |
@@ -2268,18 +2273,37 @@ sub process { | |||
2268 | } | 2273 | } |
2269 | 2274 | ||
2270 | # check for missing blank lines after declarations | 2275 | # check for missing blank lines after declarations |
2271 | if ($realfile =~ m@^(drivers/net/|net/)@ && | 2276 | if ($sline =~ /^\+\s+\S/ && #Not at char 1 |
2272 | $prevline =~ /^\+\s+$Declare\s+$Ident/ && | 2277 | # actual declarations |
2273 | !($prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ || | 2278 | ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
2274 | $prevline =~ /(?:\{\s*|\\)$/) && #extended lines | 2279 | # foo bar; where foo is some local typedef or #define |
2275 | $sline =~ /^\+\s+/ && #Not at char 1 | 2280 | $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
2276 | !($sline =~ /^\+\s+$Declare/ || | 2281 | # known declaration macros |
2277 | $sline =~ /^\+\s+$Ident\s+$Ident/ || #eg: typedef foo | 2282 | $prevline =~ /^\+\s+$declaration_macros/) && |
2283 | # for "else if" which can look like "$Ident $Ident" | ||
2284 | !($prevline =~ /^\+\s+$c90_Keywords\b/ || | ||
2285 | # other possible extensions of declaration lines | ||
2286 | $prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ || | ||
2287 | # not starting a section or a macro "\" extended line | ||
2288 | $prevline =~ /(?:\{\s*|\\)$/) && | ||
2289 | # looks like a declaration | ||
2290 | !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || | ||
2291 | # foo bar; where foo is some local typedef or #define | ||
2292 | $sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || | ||
2293 | # known declaration macros | ||
2294 | $sline =~ /^\+\s+$declaration_macros/ || | ||
2295 | # start of struct or union or enum | ||
2278 | $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ || | 2296 | $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ || |
2279 | $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(])/ || | 2297 | # start or end of block or continuation of declaration |
2280 | $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) { | 2298 | $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ || |
2299 | # bitfield continuation | ||
2300 | $sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ || | ||
2301 | # other possible extensions of declaration lines | ||
2302 | $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) && | ||
2303 | # indentation of previous and current line are the same | ||
2304 | (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) { | ||
2281 | WARN("SPACING", | 2305 | WARN("SPACING", |
2282 | "networking uses a blank line after declarations\n" . $hereprev); | 2306 | "Missing a blank line after declarations\n" . $hereprev); |
2283 | } | 2307 | } |
2284 | 2308 | ||
2285 | # check for spaces at the beginning of a line. | 2309 | # check for spaces at the beginning of a line. |