From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751299AbdBUCnD (ORCPT ); Mon, 20 Feb 2017 21:43:03 -0500 Received: from smtprelay0222.hostedemail.com ([216.40.44.222]:47720 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750977AbdBUCnC (ORCPT ); Mon, 20 Feb 2017 21:43:02 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2110:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3872:3874:4321:5007:10004:10400:10848:11232:11658:11914:12555:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21067:21080:21451:30054:30070:30091,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: lift99_8eae13e39440c X-Filterd-Recvd-Size: 2295 Message-ID: <1487644978.2853.8.camel@perches.com> Subject: Re: [PATCH] checkpatch: remove false unbalanced braces warning From: Joe Perches To: Sven Eckelmann , Andrew Morton Cc: Andy Whitcroft , linux-kernel@vger.kernel.org Date: Mon, 20 Feb 2017 18:42:58 -0800 In-Reply-To: <20170220121644.12209-1-sven@narfation.org> References: <20170220121644.12209-1-sven@narfation.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.3-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-02-20 at 13:16 +0100, Sven Eckelmann wrote: > 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 Yeah, thanks. That's what I meant to do originally. Acked-by: Joe Perches cheers, Joe > 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") > Signed-off-by: Sven Eckelmann > --- > scripts/checkpatch.pl | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index ad5ea5c545b2..baa3c7be04ad 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5107,8 +5107,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); > } >