summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2017-02-24 15:01:43 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-24 17:46:57 -0800
commit95330473636e5e4546f94874c957c3be66bb2140 (patch)
treeac0a78ccfadfd0c840b1e63fa93c8ffa28c77ada /scripts
parente4c5babd32f974cf3db4b5bdb02f23132cc81afb (diff)
downloadlinux-95330473636e5e4546f94874c957c3be66bb2140.tar.gz
linux-95330473636e5e4546f94874c957c3be66bb2140.tar.xz
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") Link: http://lkml.kernel.org/r/20170220121644.12209-1-sven@narfation.org Signed-off-by: Sven Eckelmann <sven@narfation.org> Acked-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-xscripts/checkpatch.pl4
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7fb73d92801c..918259a55f65 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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);
}