Re: [PATCH] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h

From: Mike Frysinger
Date: Sun Nov 16 2008 - 07:06:48 EST


On Wednesday 12 November 2008 09:02:50 Andy Whitcroft wrote:
> On Sat, Nov 08, 2008 at 05:56:05PM -0500, Mike Frysinger wrote:
> > Seems like every other release we have someone who updates vmlinux.lds.h
> > and adds C-visible symbols without VMLINUX_SYMBOL() around them. So
> > start checking the file and only allow assignments that use one of the
> > following symbols on a side:
> > .
> > ALIGN(...)
> > VMLINUX_SYMBOL(...)
> >
> > Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx>
> > ---
> > scripts/checkpatch.pl | 13 +++++++++++++
> > 1 files changed, 13 insertions(+), 0 deletions(-)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index f88bb3e..8e96b42 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2189,6 +2189,19 @@ sub process {
> > }
> > }
> >
> > +# make sure symbols are always wrapped with VMLINUX_SYMBOL() ...
> > +# all assignments may have only one of the following with an assignment:
> > +# .
> > +# ALIGN(...)
> > +# VMLINUX_SYMBOL(...)
> > + if ($realfile =~ /vmlinux.lds.h$/) {
> > + if ($line =~ /=/ &&
> > + !($line =~
> > /([.]|(ALIGN|VMLINUX_SYMBOL)[(][^=]*[)])\s*=\s*([.]|(ALIGN|VMLINUX_SYMBOL
> >)[(][^=]*[)])/)) + {
> > + WARN("vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible
> > symbols\n" . $herecurr); + }
> > + }
> > +
> > # check for redundant bracing round if etc
> > if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) {
> > my ($level, $endln, @chunks) =
> > --
>
> Ok, that seems like a sane check. I think what we are really wanting
> to check for is assigments with plain identifiers on either side? I've
> pushed a softened version of this check to my tree for testing.
>
>
> http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl-
>testing

perl isnt my thing so i'm going to assume what you added does as intended (i
dont really get the regex statement you've added)

all i was using to test was to edit the file and remove VMLINUX_SYMBOL() from
a place or two and then do:
diff -Nur /dev/null include/asm-generic/vmlinux.lds.h |
./scripts/checkpatch.pl

thanks for adding this ... it'll save me consistent pain :)
-mike

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/