From: Joe Perches Date: Wed, 6 Aug 2014 23:10:39 +0000 (-0700) Subject: checkpatch: add test for blank lines after function/struct/union/enum X-Git-Tag: v4.9.8~5947^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7f61919144ca69ea29f29c3e60c5b7dbd2070aa6;p=platform%2Fkernel%2Flinux-rpi3.git checkpatch: add test for blank lines after function/struct/union/enum 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c40ba40..9e4ba9f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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