[<prev] [next>] [day] [month] [year] [list]
Message-Id: <c6be32747fc725cbc235802991746700a0f54fdc.1486754390.git.joe@perches.com>
Date: Fri, 10 Feb 2017 11:20:21 -0800
From: Joe Perches <joe@...ches.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Andy Whitcroft <apw@...onical.com>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] checkpatch: Notice unbalanced else braces in a patch
Patches that add or modify code like
} else
<foo>
or
else {
<bar>
where one branch appears to have a brace and the other branch
does not have a brace should emit a --strict style message.
Signed-off-by: Joe Perches <joe@...ches.com>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8e96af53611c..ad5ea5c545b2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5106,6 +5106,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",
--
2.10.0.rc2.1.g053435c
Powered by blists - more mailing lists