Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758943AbdLRPNG (ORCPT ); Mon, 18 Dec 2017 10:13:06 -0500 Received: from smtprelay0154.hostedemail.com ([216.40.44.154]:55794 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933021AbdLRPMy (ORCPT ); Mon, 18 Dec 2017 10:12:54 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:2691:2828:3138:3139:3140:3141:3142:3352:3622:3653:3865:3866:3868:3871:3872:3874:4321:4605:5007:6119:6142:6143:10004:10400:10848:11232:11657:11658:11914:12679:12740:12760:12895:13069:13161:13229:13311:13357:13439:14181:14659:14721:21080:21221:21451:21627:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: nail30_8d7cab17c2c63 X-Filterd-Recvd-Size: 1804 Message-ID: <1513609970.31581.62.camel@perches.com> Subject: Re: [PATCH] checkpatch: fix for stripping brackets from macros. From: Joe Perches To: Jeremy Sowden , linux-kernel@vger.kernel.org, apw@canonical.com Date: Mon, 18 Dec 2017 07:12:50 -0800 In-Reply-To: <20171218141716.26227-1-jeremy@azazel.net> References: <20171218141716.26227-1-jeremy@azazel.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-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 Content-Length: 1044 Lines: 34 On Mon, 2017-12-18 at 14:17 +0000, Jeremy Sowden wrote: > When checking macros, checkpatch.pl strips parentheses, square brackets > and braces. However, the search-and-replace expression was not correct, > and instead of replacing the brackets and their contents with just the > contents, it was replacing them with literal 1's. Jeremy: What is the effect on the rest of the block that uses this substituted $dstat? Why should this be done? Andy: I believe this is intentional as it simplifies the macro analysis and has no other effect on the rest of the block. Correct? > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -4874,9 +4874,9 @@ sub process { > $dstat =~ s/\s*$//s; > > # Flatten any parentheses and braces > - while ($dstat =~ s/\([^\(\)]*\)/1/ || > - $dstat =~ s/\{[^\{\}]*\}/1/ || > - $dstat =~ s/.\[[^\[\]]*\]/1/) > + while ($dstat =~ s/\(([^\(\)]*)\)/$1/ || > + $dstat =~ s/\{([^\{\}]*)\}/$1/ || > + $dstat =~ s/.\[([^\[\]]*)\]/$1/) > { > }