Skip to content

Commit 74c8f43

Browse files
matthijskooijmantorvalds
authored andcommitted
checkpatch: only warn for empty lines before closing braces by themselves
This check was intended to catch extra newlines at the end of a function definition, but it would trigger on any closing brace, including those of inline functions and macro definitions, triggering false positives. Now, only closing braces on a line by themselves trigger this check. Tested with: $ cat test.h /* test.h - Test file */ static inline int foo(void) { return 0; } static inline int bar(void) { return 1; } $ ./scripts/checkpatch.pl --strict -f test.h # Before this commit CHECK: Blank lines aren't necessary before a close brace '}' + +static inline int foo(void) { return 0; } CHECK: Blank lines aren't necessary before a close brace '}' + +} total: 0 errors, 0 warnings, 2 checks, 9 lines checked $ ./scripts/checkpatch.pl --strict -f test.h # After this commit CHECK: Blank lines aren't necessary before a close brace '}' + +} total: 0 errors, 0 warnings, 1 checks, 9 lines checked Signed-off-by: Matthijs Kooijman <[email protected]> Cc: Andy Whitcroft <[email protected]> Acked-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5646bc7 commit 74c8f43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/checkpatch.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3229,7 +3229,7 @@ sub process {
32293229
}
32303230

32313231
# check for unnecessary blank lines around braces
3232-
if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
3232+
if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) {
32333233
CHK("BRACES",
32343234
"Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
32353235
}

0 commit comments

Comments
 (0)