checkpatch: remove false unbalanced braces warning
PATCH 124/124 checkpatch: remove false unbalanced braces warning
From: Sven Eckelmann <[email protected]>
Subject: checkpatch: remove false unbalanced braces warning
Lines containing "} else {" should not be detected as unbalanced braces. But the second check can be reduced to ".+else\s*{" and it therefore never checked if the beginning of a line contains any other character (like the relevant "}"). This check would also return true for "} else {" and create warnings like
CHECK: Unbalanced braces around else statement #391: FILE: ./net/batman-adv/tvlv.c:391:
+ } else {
The check can be changed to check the whole line for the missing "}" to avoid this false positive.
Fixes 0d1532456c26 ("checkpatch: notice unbalanced else braces in a patch")
Signed-off-by Sven Eckelmann <[email protected]>
Acked-by Joe Perches <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-remove-false-unbalanced-braces-warning +2 -2
@@ -5105,8 +5105,8 @@ sub process { } # check for single line unbalanced braces - if ($sline =~ /.\s*\}\s*else\s*$/ || - $sline =~ /.\s*else\s*\{\s*$/) { + if ($sline =~ /^.\s*\}\s*else\s*$/ || + $sline =~ /^.\s*else\s*\{\s*$/) { CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr); }
_