Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932114AbdBJTU0 (ORCPT ); Fri, 10 Feb 2017 14:20:26 -0500 Received: from smtprelay0216.hostedemail.com ([216.40.44.216]:35097 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753297AbdBJTUZ (ORCPT ); Fri, 10 Feb 2017 14:20:25 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1345:1437:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3874:4321:5007:6261:10004:10848:11658:11914:12555:12895:13069:13095:13311:13357:14181:14384:14394:14721:14827:21062:21063:21080:21433:30012:30054:30070,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: game96_3d929a2f19c01 X-Filterd-Recvd-Size: 1521 From: Joe Perches To: Andrew Morton , Andy Whitcroft Cc: linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: Notice unbalanced else braces in a patch Date: Fri, 10 Feb 2017 11:20:21 -0800 Message-Id: X-Mailer: git-send-email 2.10.0.rc2.1.g053435c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Joe Perches --- 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