diff options
| author | Joe Perches <joe@perches.com> | 2014-08-06 19:10:39 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-06 21:01:27 -0400 |
| commit | 7f61919144ca69ea29f29c3e60c5b7dbd2070aa6 (patch) | |
| tree | a3aafc8267a3d2d8c898cc11a198303ca1c5fa83 /scripts | |
| parent | 048b123fad06f33169caa4afd6d56d58c31517e5 (diff) | |
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 <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 | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c40ba40cef43..9e4ba9fa9bc8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -2292,6 +2292,22 @@ sub process { | |||
| 2292 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); | 2292 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); |
| 2293 | } | 2293 | } |
| 2294 | 2294 | ||
| 2295 | # check for missing blank lines after struct/union declarations | ||
| 2296 | # with exceptions for various attributes and macros | ||
| 2297 | if ($prevline =~ /^[\+ ]};?\s*$/ && | ||
| 2298 | $line =~ /^\+/ && | ||
| 2299 | !($line =~ /^\+\s*$/ || | ||
| 2300 | $line =~ /^\+\s*EXPORT_SYMBOL/ || | ||
| 2301 | $line =~ /^\+\s*MODULE_/i || | ||
| 2302 | $line =~ /^\+\s*\#\s*(?:end|elif|else)/ || | ||
| 2303 | $line =~ /^\+[a-z_]*init/ || | ||
| 2304 | $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ || | ||
| 2305 | $line =~ /^\+\s*DECLARE/ || | ||
| 2306 | $line =~ /^\+\s*__setup/)) { | ||
| 2307 | CHK("LINE_SPACING", | ||
| 2308 | "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev); | ||
| 2309 | } | ||
| 2310 | |||
| 2295 | # check for missing blank lines after declarations | 2311 | # check for missing blank lines after declarations |
| 2296 | if ($sline =~ /^\+\s+\S/ && #Not at char 1 | 2312 | if ($sline =~ /^\+\s+\S/ && #Not at char 1 |
| 2297 | # actual declarations | 2313 | # actual declarations |
