All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h
@ 2008-11-08 22:56 Mike Frysinger
  2008-11-12 14:02 ` Andy Whitcroft
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2008-11-08 22:56 UTC (permalink / raw)
  To: Andy Whitcroft, Andrew Morton; +Cc: linux-kernel

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@gentoo.org>
---
 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) =
-- 
1.6.0.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h
  2008-11-08 22:56 [PATCH] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h Mike Frysinger
@ 2008-11-12 14:02 ` Andy Whitcroft
  2008-11-16 12:06   ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Whitcroft @ 2008-11-12 14:02 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Andrew Morton, linux-kernel

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@gentoo.org>
> ---
>  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

-apw

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h
  2008-11-12 14:02 ` Andy Whitcroft
@ 2008-11-16 12:06   ` Mike Frysinger
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2008-11-16 12:06 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: Andrew Morton, linux-kernel

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@gentoo.org>
> > ---
> >  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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-16 12:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-08 22:56 [PATCH] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h Mike Frysinger
2008-11-12 14:02 ` Andy Whitcroft
2008-11-16 12:06   ` Mike Frysinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.