From 0a8371bdfdd88e662d09def717cc0b822feb64e8 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Mon, 29 Sep 2014 17:27:14 -0400 Subject: extras: reverse test for '}' vs. following 'else' placement The two-line form "}\nelse {" has been more common than the one-line form "} else {" in our code for years, and IMO for good reason (see the comment in the diff). Change-Id: Ic22c76fe76f0d91300daff36e755a18a8db58852 Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.org/8888 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- extras/checkpatch.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extras/checkpatch.pl b/extras/checkpatch.pl index 02c2c2e02ee..18e8cc7aac7 100755 --- a/extras/checkpatch.pl +++ b/extras/checkpatch.pl @@ -3335,12 +3335,12 @@ sub process { "trailing statements should be on next line\n" . $herecurr); } - # Check for }else {, these must be at the same - # indent level to be relevant to each other. - if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and - $previndent == $indent) { + # Check for "} else" which is less readable. Having if/else keywords + # line up is a good thing, and having control structures on the same + # line as a close-brace is bad. + if ($line=~/^.\s*}\selse\s*/) { ERROR("ELSE_AFTER_BRACE", - "else should follow close brace '}'\n" . $hereprev); + "'}' and 'else' should be on separate lines\n" . $hereprev); } if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and -- cgit