From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758074AbbJ2WqZ (ORCPT ); Thu, 29 Oct 2015 18:46:25 -0400 Received: from smtprelay0056.hostedemail.com ([216.40.44.56]:55981 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757188AbbJ2WqY (ORCPT ); Thu, 29 Oct 2015 18:46:24 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:560: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:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:4321:4605:5007:6261:7903:7904:10004:10400:10848:11026:11232:11473:11657:11658:11914:12296:12438:12517:12519:12555:12663:12740:13019:13069:13311:13357:21080:30034: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: apple46_71dbd2b30460a X-Filterd-Recvd-Size: 2585 Message-ID: <1446158781.2757.182.camel@perches.com> Subject: Re: [PATCH] checkpatch: fix a number of COMPLEX_MACRO false positives From: Joe Perches To: Vladimir Zapolskiy Cc: Andy Whitcroft , Andrew Morton , linux-kernel@vger.kernel.org Date: Thu, 29 Oct 2015 15:46:21 -0700 In-Reply-To: <1446154613-8249-1-git-send-email-vz@mleia.com> References: <1446154613-8249-1-git-send-email-vz@mleia.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 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 Thu, 2015-10-29 at 23:36 +0200, Vladimir Zapolskiy wrote: > A simple search over the kernel souce displays a number of correctly > defined multiline macro, which generally are used as an array element > initializer: > > % find ../linux -type f | xargs grep -B1 -H '^[:space]*\[.*\\$' > > However checkpatch.pl unexpectedly complains about all these macro > definitions: > > % ./scripts/checkpatch.pl --types COMPLEX_MACRO -f include/linux/perf/arm_pmu.h > > ERROR: Macros with complex values should be enclosed in parentheses > +#define PERF_MAP_ALL_UNSUPPORTED \ > + [0 ... PERF_COUNT_HW_MAX - 1] = HW_OP_UNSUPPORTED > > The change intends to fix this type of false positives by flattening > only array members and skipping array element designators. > > Signed-off-by: Vladimir Zapolskiy > --- > scripts/checkpatch.pl | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index f2a1131..3882893 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -4526,7 +4526,7 @@ sub process { > # Flatten any parentheses and braces > while ($dstat =~ s/\([^\(\)]*\)/1/ || > $dstat =~ s/\{[^\{\}]*\}/1/ || > - $dstat =~ s/\[[^\[\]]*\]/1/) > + $dstat =~ s/.\[[^\[\]]*\]/1/) Perhaps the . before the [ might be a bit broad. I'm not sure there's a great way to handle this. Andy? > { > } > > @@ -4546,7 +4546,8 @@ sub process { > union| > struct| > \.$Ident\s*=\s*| > - ^\"|\"$ > + ^\"|\"$| > + ^\[ > }x; > #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; > if ($dstat ne '' &&