lkml.org 
[lkml]   [2019]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: checkpatch.pl should suggest __section
On Fri, Aug 9, 2019 at 4:17 PM Joe Perches <joe@perches.com> wrote:
>
> On Fri, 2019-08-09 at 16:04 -0700, Nick Desaulniers wrote:
> > > how about:
> > > ---
> > > scripts/checkpatch.pl | 9 +++++++++
> > > 1 file changed, 9 insertions(+)
> > >
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > > index 1cdacb4fd207..8e6693ca772c 100755
> > > --- a/scripts/checkpatch.pl
> > > +++ b/scripts/checkpatch.pl
> > > @@ -5901,6 +5901,15 @@ sub process {
> > > "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
> > > }
> > >
> > > +# Check for __attribute__ section, prefer __section (without quotes)
> > > + if ($realfile !~ m@\binclude/uapi/@ &&
> > > + $line =~ /\b__attribute__\s*\(\s*\(.*_*section_*\s*\(\s*("[^"]*")/) {
> > > + my $old = substr($rawline, $-[1], $+[1] - $-[1]);
> > > + my $new = substr($old, 1, -1);
> > > + WARN("PREFER_SECTION",
> > > + "__section($new) is preferred over __attribute__((section($old)))\n" . $herecurr);
> > > + }
> > > +
> >
> > I can't read Perl, but this looks pretty good.
> > Acked-by: Nick Desaulniers <ndesaulniers@google.com>
>
> I'll add a Suggested-by: for you.
>
> But a Tested-by would be more valuable than an Acked-by if you
> don't actually know how it works.

$ git am joes.patch
$ echo "int foo __attribute__((section(.hello)));" >> arch/x86/boot/a20.c
$ git commit arch/x86/boot/a20.c -sm "foo: bar\n baz"
$ git format-patch HEAD~
$ ./scripts/checkpatch.pl 0001-foo-bar.patch
total: 0 errors, 0 warnings, 4 lines checked

0001-foo-bar.patch has no obvious style problems and is ready for submission.

hmm...
--
Thanks,
~Nick Desaulniers

\
 
 \ /
  Last update: 2019-08-12 20:21    [W:0.055 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site