[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABJPP5AcjAq0kg0MMggd2D6YUwVhq96otm-qQB3Snddt77VxAA@mail.gmail.com>
Date: Sat, 24 Oct 2020 02:27:05 +0530
From: Dwaipayan Ray <dwaipayanray1@...il.com>
To: Joe Perches <joe@...ches.com>
Cc: linux-kernel-mentees@...ts.linuxfoundation.org,
linux-kernel <linux-kernel@...r.kernel.org>,
Lukas Bulwahn <lukas.bulwahn@...il.com>
Subject: Re: [PATCH RFC v2] checkpatch: extend attributes check to handle more patterns
On Sat, Oct 24, 2020 at 2:12 AM Joe Perches <joe@...ches.com> wrote:
>
> On Sat, 2020-10-24 at 00:44 +0530, Dwaipayan Ray wrote:
> > Hi,
>
> Hi again.
>
> > I modified the check to check the attributes from the map.
> > There are two checks - one for the normal attributes and
> > one for the ones with arguments, which needs just a bit more
> > processing.
> >
> > So attributes like __packed__ as well as those like
> > __aligned__(x) are handled.
> >
> > What do you think?
> >
> > ---
> > + $line =~ /__attribute__\s*\(\s*($balanced_parens)\s*\)/)
> > {
> > + my $attr = trim($1);
> > + $attr =~ s/\(\s*_*(.*)\)/$1/;
> > + while($attr =~ s/(.*)_$/$1/) {} # Remove trailing
> > underscores
>
> I think this could be a single test like:
>
> while ($attr =~ /\s*(\w+)\s*(${balanced_parens})?/g) {
> my $curr_attr = $1;
> my $parens = $2;
> $curr_attr = s/^_*(.*)_*$/$1/;
>
Thanks, I will do that.
Also I tried the pattern attr =~ s/^_*(.*)_*$/$1/
for trimming the _ earlier. I think it doesn't trim the
trailing underscores in the suffix as (.*) captures everything greedily.
Is the iterative one perhaps okay instead?
while($attr =~ s/(.*)_$/$1/) {}
> > + my %attr_list = (
> > + "alias" => "__alias",
> > + "aligned" => "__aligned",
>
> These might be better using tab alignment.
>
> And you might special case format(printf/scanf here too
Yes I think they are special cases now too. I didn't post the
entire context, so my mistake.
Thanks,
Dwaipayan.
Powered by blists - more mailing lists