From: Vladimir Zapolskiy <vz@mleia.com>
To: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: fix a number of COMPLEX_MACRO false positives
Date: Fri, 30 Oct 2015 01:52:05 +0200 [thread overview]
Message-ID: <5632B125.4080009@mleia.com> (raw)
In-Reply-To: <1446158781.2757.182.camel@perches.com>
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 <vz@mleia.com>
>> ---
>> 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
next prev parent reply other threads:[~2015-10-29 23:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 21:36 [PATCH] checkpatch: fix a number of COMPLEX_MACRO false positives Vladimir Zapolskiy
2015-10-29 22:46 ` Joe Perches
2015-10-29 23:52 ` Vladimir Zapolskiy [this message]
2015-11-10 18:01 ` Vladimir Zapolskiy
2015-11-10 18:08 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5632B125.4080009@mleia.com \
--to=vz@mleia.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox