Re: [PATCH RFC] checkpatch: fix multi-statement macro checks
From: Dwaipayan Ray
Date: Thu Oct 01 2020 - 11:36:58 EST
> > All I'm trying to point out to you is that $Constant\s*$Constant
> > isn't a proper test as the first $Constant will pull the test
> > entire sequence of digits and the second $Constant will not be
> > met.
> >
> > It may take some conversion of the collapsing of the dstat
> > block to work appropriately
> >
> >
> > # Flatten any parentheses and braces
> > while ($dstat =~ s/\([^\(\)]*\)/1/ ||
> > $dstat =~ s/\{[^\{\}]*\}/1/ ||
> > $dstat =~ s/.\[[^\[\]]*\]/1/)
> > {
> > }
> >
> > Maybe the /1/ should be / 1 / but I didn't look to see what
> > happens to the exclusion tests below that.
>
> I think your patch would work well enough if the /1/ bits
> here were simply changed to /1u/.
>
> 1 is a $Constant as it's just a number.
> 11 though is also a $Constant.
> 1u is also a $Constant but it stops the acquisition of
> digits that 11 would not and the sequence of
> "while1u1u" should match your newly introduced test
> of $Constant\s*$Constant as "while11" would not match.
>
>
Hi,
That's an amazing idea! I tried it and this time it seems to
detect it properly. Also this fixes the similar case in
for(...) {...}.
It should not have any side effects also for other checks.
Pretty amazing.
I will rewrite the patch with your suggestion and send it
back.
Thanks,
Dwaipayan.