From: Joe Perches Date: Fri, 24 Feb 2017 23:01:41 +0000 (-0800) Subject: checkpatch: notice unbalanced else braces in a patch X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e4c5babd32f974cf3db4b5bdb02f23132cc81afb;p=openwrt%2Fstaging%2Fblogic.git checkpatch: notice unbalanced else braces in a patch Patches that add or modify code like } else or else { where one branch appears to have a brace and the other branch does not have a brace should emit a --strict style message. Link: http://lkml.kernel.org/r/c6be32747fc725cbc235802991746700a0f54fdc.1486754390.git.joe@perches.com Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 12db1483e6c2..7fb73d92801c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5104,6 +5104,12 @@ sub process { } } +# check for single line unbalanced braces + if ($sline =~ /.\s*\}\s*else\s*$/ || + $sline =~ /.\s*else\s*\{\s*$/) { + CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr); + } + # check for unnecessary blank lines around braces if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) { if (CHK("BRACES",