[PATCH] checkpatch: statement should end at a close brace at the outermost level.

From: Jiang Biao
Date: Tue Oct 10 2017 - 23:45:53 EST


Statement should end at a close brace at the outermost level in
ctx_statement_block.

The way to reproduce the bug,
1, Add two external function declarations into line 505 of
kernel/stop_machine.c, such as,
int foo1(void);
int foo2(void);
2, Format a patch for that, and use the checkpatch.pl to check.
3, The first declaration(foo1()) would not be warned, because the
statement does not end at the '}' before it.

Signed-off-by: Jiang Biao <jiang.biao2@xxxxxxxxxx>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dd2c262..f220cfc 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1330,7 +1330,7 @@ sub ctx_statement_block {

# Statement ends at the ';' or a close '}' at the
# outermost level.
- if ($level == 0 && $c eq ';') {
+ if ($level == 0 && ($c eq ';' || $c eq '}')) {
last;
}

--
2.7.4