From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758277AbbJ2XwJ (ORCPT ); Thu, 29 Oct 2015 19:52:09 -0400 Received: from mleia.com ([178.79.152.223]:53849 "EHLO mail.mleia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbbJ2XwI (ORCPT ); Thu, 29 Oct 2015 19:52:08 -0400 Message-ID: <5632B125.4080009@mleia.com> Date: Fri, 30 Oct 2015 01:52:05 +0200 From: Vladimir Zapolskiy User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Joe Perches CC: Andy Whitcroft , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] checkpatch: fix a number of COMPLEX_MACRO false positives References: <1446154613-8249-1-git-send-email-vz@mleia.com> <1446158781.2757.182.camel@perches.com> In-Reply-To: <1446158781.2757.182.camel@perches.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-49551924 X-CRM114-CacheID: sfid-20151029_235230_144847_6E4821F3 X-CRM114-Status: GOOD ( 19.11 ) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.10.2015 00:46, Joe Perches wrote: > 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. At this point preceding spaces and parentheses are removed, probably any alphanumeric symbol should fit here. OTOH I believe in correct C code here before \[ symbol you may find only an alphanumeric symbol or ^, so I don't expect any false negatives, if . is used above. > 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 '' && > > > -- With best wishes, Vladimir