* [PATCH] checkpatch: Only warn for empty lines before closing braces by themselves
@ 2013-04-10 8:49 Matthijs Kooijman
2013-04-11 18:46 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Matthijs Kooijman @ 2013-04-10 8:49 UTC (permalink / raw)
To: Joe Perches, Andy Whitcroft; +Cc: linux-kernel
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 <matthijs@stdin.nl>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 532c41b..f962c30 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3236,7 +3236,7 @@ sub process {
}
# check for unnecessary blank lines around braces
- if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
+ if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) {
CHK("BRACES",
"Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
}
--
1.8.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] checkpatch: Only warn for empty lines before closing braces by themselves
2013-04-10 8:49 [PATCH] checkpatch: Only warn for empty lines before closing braces by themselves Matthijs Kooijman
@ 2013-04-11 18:46 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2013-04-11 18:46 UTC (permalink / raw)
To: Matthijs Kooijman, Andrew Morton; +Cc: Andy Whitcroft, linux-kernel
On Wed, 2013-04-10 at 10:49 +0200, Matthijs Kooijman wrote:
> 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.
[]
> Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Joe Perches <joe@perches.com>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 532c41b..f962c30 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3236,7 +3236,7 @@ sub process {
> }
>
> # check for unnecessary blank lines around braces
> - if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
> + if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) {
> CHK("BRACES",
> "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-11 18:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10 8:49 [PATCH] checkpatch: Only warn for empty lines before closing braces by themselves Matthijs Kooijman
2013-04-11 18:46 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®