linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Dwaipayan Ray <dwaipayanray1@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [Linux-kernel-mentees] [PATCH v4] checkpatch: extend attributes check to handle more patterns
Date: Sun, 25 Oct 2020 14:02:32 +0530	[thread overview]
Message-ID: <CABJPP5D9ziuyPpPPyPM+n101vT1LGEjHj+JQjOhdN533t8Ud7w@mail.gmail.com> (raw)
In-Reply-To: <e96f8306d57e9a2ce7118b545db197e819e97b19.camel@perches.com>

On Sun, Oct 25, 2020 at 1:52 PM Joe Perches <joe@perches.com> wrote:
>
> On Sun, 2020-10-25 at 12:21 +0530, Dwaipayan Ray wrote:
> > It is generally preferred that the macros from
> > include/linux/compiler_attributes.h are used, unless there
> > is a reason not to.
> >
> > checkpatch currently checks __attribute__ for each of
> > packed, aligned, printf, scanf, and weak. Other declarations
> > in compiler_attributes.h are not handled.
> >
> > Add a generic test to check the presence of such attributes.
> > Some attributes require more specific handling and are kept
> > separate.
> []
> > Also add fixes for the generic attributes check.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > +                             if (exists($attr_list{$curr_attr})) {
> > +                                     my $new = $attr_list{$curr_attr};
> > +                                     if (WARN("PREFER_DEFINED_ATTRIBUTE_MACRO",
> > +                                              "$new$params is preferred over __attribute__(($attr))\n" . $herecurr) &&
> > +                                             $fix) {
> > +                                             $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*\Q$attr\E\s*\)\s*\)/$new$params/;
>
> Thanks.
>
> This fix would only work for the single conversions
> and would not work for multiple attributes like:
>
>         __attribute__((aligned(4), packed))
>
> It would be nice to be able to convert this to
>
>         __aligned(4) __packed
>
> One mechanism to do that might be to:
>
>         create an empty array
>         for each attr
>                 push(@array, conversion)
>         s/__attribute__(...)/join(' ', @array)/
>
> if all attrs were converted.
>

Okay sure I will try doing that.

I think I need to also change the test to correctly display
the warning for those having multiple attributes too.
Because now only single attributes are reported.

And also do you think there should be a separate check
for __alias__(#symbol)? I think it expects a string and that should
be trimmed in the fix.

Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2020-10-25  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-25  6:51 [Linux-kernel-mentees] [PATCH v4] checkpatch: extend attributes check to handle more patterns Dwaipayan Ray
2020-10-25  8:22 ` Joe Perches
2020-10-25  8:32   ` Dwaipayan Ray [this message]
2020-10-25  8:38     ` Joe Perches
2020-10-25  8:42       ` Dwaipayan Ray
2020-10-25  8:48         ` 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=CABJPP5D9ziuyPpPPyPM+n101vT1LGEjHj+JQjOhdN533t8Ud7w@mail.gmail.com \
    --to=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --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;
as well as URLs for NNTP newsgroup(s).