aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-04-03 17:49:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:21:15 -0400
commit3b617e3b80548096eda92ebd8382f76b139e011c (patch)
treee2613eb994f3ff9c89bdcf21a954c8fbcdd0bc0e /scripts
parentcc93319b5f2471ff2042ce62ea6da1f3bb3ce394 (diff)
checkpatch: net and drivers/net: warn on missing blank line after variable declaration
Networking prefers this style, so warn when it's not used. Networking uses: void foo(int bar) { int baz; code... } not void foo(int bar) { int baz; code... } There are a limited number of false positives when using macros to declare variables like: WARNING: networking uses a blank line after declarations #330: FILE: net/ipv4/inet_hashtables.c:330: + int dif = sk->sk_bound_dev_if; + INET_ADDR_COOKIE(acookie, saddr, daddr) Signed-off-by: Joe Perches <joe@perches.com> Cc: David Miller <davem@davemloft.net> 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.pl15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 921c037f1968..33072d6c1b5a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2257,6 +2257,21 @@ sub process {
2257 "networking block comments put the trailing */ on a separate line\n" . $herecurr); 2257 "networking block comments put the trailing */ on a separate line\n" . $herecurr);
2258 } 2258 }
2259 2259
2260# check for missing blank lines after declarations
2261 if ($realfile =~ m@^(drivers/net/|net/)@ &&
2262 $prevline =~ /^\+\s+$Declare\s+$Ident/ &&
2263 !($prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
2264 $prevline =~ /(?:\{\s*|\\)$/) && #extended lines
2265 $sline =~ /^\+\s+/ && #Not at char 1
2266 !($sline =~ /^\+\s+$Declare/ ||
2267 $sline =~ /^\+\s+$Ident\s+$Ident/ || #eg: typedef foo
2268 $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ ||
2269 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(])/ ||
2270 $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) {
2271 WARN("SPACING",
2272 "networking uses a blank line after declarations\n" . $hereprev);
2273 }
2274
2260# check for spaces at the beginning of a line. 2275# check for spaces at the beginning of a line.
2261# Exceptions: 2276# Exceptions:
2262# 1) within comments 2277# 1) within comments