Skip to content

Commit

Permalink
checkpatch: add test for blank lines after function/struct/union/enum
Browse files Browse the repository at this point in the history
Add a --strict test asking for a blank line after
function/struct/union/enum declarations.

Allow exceptions for several attributes and macro uses.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Aug 7, 2014
1 parent 048b123 commit 7f61919
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,22 @@ sub process {
"networking block comments put the trailing */ on a separate line\n" . $herecurr);
}

# check for missing blank lines after struct/union declarations
# with exceptions for various attributes and macros
if ($prevline =~ /^[\+ ]};?\s*$/ &&
$line =~ /^\+/ &&
!($line =~ /^\+\s*$/ ||
$line =~ /^\+\s*EXPORT_SYMBOL/ ||
$line =~ /^\+\s*MODULE_/i ||
$line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
$line =~ /^\+[a-z_]*init/ ||
$line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
$line =~ /^\+\s*DECLARE/ ||
$line =~ /^\+\s*__setup/)) {
CHK("LINE_SPACING",
"Please use a blank line after function/struct/union/enum declarations\n" . $hereprev);
}

# check for missing blank lines after declarations
if ($sline =~ /^\+\s+\S/ && #Not at char 1
# actual declarations
Expand Down

0 comments on commit 7f61919

Please sign in to comment.