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>
This commit is contained in:
parent
185d566bcd
commit
3f7bac031c
1 changed files with 34 additions and 10 deletions
|
@ -397,6 +397,11 @@ foreach my $entry (@mode_permission_funcs) {
|
||||||
$mode_perms_search .= $entry->[0];
|
$mode_perms_search .= $entry->[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
our $declaration_macros = qr{(?x:
|
||||||
|
(?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|
|
||||||
|
(?:$Storage\s+)?LIST_HEAD\s*\(
|
||||||
|
)};
|
||||||
|
|
||||||
our $allowed_asm_includes = qr{(?x:
|
our $allowed_asm_includes = qr{(?x:
|
||||||
irq|
|
irq|
|
||||||
memory
|
memory
|
||||||
|
@ -2268,18 +2273,37 @@ sub process {
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for missing blank lines after declarations
|
# check for missing blank lines after declarations
|
||||||
if ($realfile =~ m@^(drivers/net/|net/)@ &&
|
if ($sline =~ /^\+\s+\S/ && #Not at char 1
|
||||||
$prevline =~ /^\+\s+$Declare\s+$Ident/ &&
|
# actual declarations
|
||||||
!($prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
|
($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
|
||||||
$prevline =~ /(?:\{\s*|\\)$/) && #extended lines
|
# foo bar; where foo is some local typedef or #define
|
||||||
$sline =~ /^\+\s+/ && #Not at char 1
|
$prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
|
||||||
!($sline =~ /^\+\s+$Declare/ ||
|
# known declaration macros
|
||||||
$sline =~ /^\+\s+$Ident\s+$Ident/ || #eg: typedef foo
|
$prevline =~ /^\+\s+$declaration_macros/) &&
|
||||||
|
# for "else if" which can look like "$Ident $Ident"
|
||||||
|
!($prevline =~ /^\+\s+$c90_Keywords\b/ ||
|
||||||
|
# other possible extensions of declaration lines
|
||||||
|
$prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
|
||||||
|
# not starting a section or a macro "\" extended line
|
||||||
|
$prevline =~ /(?:\{\s*|\\)$/) &&
|
||||||
|
# looks like a declaration
|
||||||
|
!($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
|
||||||
|
# foo bar; where foo is some local typedef or #define
|
||||||
|
$sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
|
||||||
|
# known declaration macros
|
||||||
|
$sline =~ /^\+\s+$declaration_macros/ ||
|
||||||
|
# start of struct or union or enum
|
||||||
$sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ ||
|
$sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ ||
|
||||||
$sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(])/ ||
|
# start or end of block or continuation of declaration
|
||||||
$sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) {
|
$sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
|
||||||
|
# bitfield continuation
|
||||||
|
$sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ ||
|
||||||
|
# other possible extensions of declaration lines
|
||||||
|
$sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
|
||||||
|
# indentation of previous and current line are the same
|
||||||
|
(($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
|
||||||
WARN("SPACING",
|
WARN("SPACING",
|
||||||
"networking uses a blank line after declarations\n" . $hereprev);
|
"Missing a blank line after declarations\n" . $hereprev);
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for spaces at the beginning of a line.
|
# check for spaces at the beginning of a line.
|
||||||
|
|
Loading…
Add table
Reference in a new issue