lkml.org 
[lkml]   [2003]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v3] check headers for complete includes, etc.
On Wed, 1 October 2003 18:39:30 +0200, Sam Ravnborg wrote:
> On Wed, Oct 01, 2003 at 11:48:25AM +0200, Jörn Engel wrote:
> >
> > +my $verbose = 1; # TODO make this optional
> Could you make this controlable with option -verbose, see below.

-v or --verbose

> > +my @headers = sort(map({prune($_);}
> > + `(cd include/ && find linux -name "*.h" ; find asm/ -name "*.h")`));
> 1) you uses include but asm/ - use final '/' for consistency.
> 2) Using asm/ you require the symlink to be present. Which obvious
> it a most when doing this check, so we better secure that.

A bit better now, but still not too nice.

> > +my $basename = "lib/header";
> I much rather have it be: include/headercheck
> then people realise where eventual temporary files comes from.

Doesn't work in include/, there is no include/Makefile. But lib/ is a
hack, I agree.

> So we need something like the following here: (untested)
> >
> > +headercheck: prepare-all
> > + $(PERL) scripts/checkheader.pl $(if $(KBUILD_VERBOSE),-verbose)
> > +

What is prepare-all supposed to do? Target doesn't exist.
Changed option to --verbose, see above.

make headercheck, make V=0 headercheck and make V=1 headercheck are
all verbose. Is this intended?

Jörn

--
Victory in war is not repetitious.
-- Sun Tzu

--- /dev/null 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-test5/scripts/checkheader.pl 2003-10-01 19:54:26.000000000 +0200
@@ -0,0 +1,63 @@
+#!/usr/bin/perl -w
+use strict;
+use Getopt::Long;
+
+Getopt::Long::Configure("no_auto_abbrev"); # Could cause unexpected things
+Getopt::Long::Configure("bundling"); # We want -sA to work
+Getopt::Long::Configure("no_ignore_case"); # We don't want -a == -A
+
+my $verbose = 0;
+
+GetOptions('v|verbose' => \$verbose) || die("bad options");
+
+
+sub prune($)
+{
+ my $h = shift;
+ chomp($h);
+ open(HDR, "include/$h")
+ or return;
+ while (<HDR>) {
+ if ($_ =~ /^#\s*define\s+PRAGMA_INDIRECT_HEADER\s/) {
+ return;
+ }
+ }
+ close(HDR);
+ return $h;
+}
+
+my @headers = sort(map({prune($_);} `(cd include/ &&
+ [ -d linux/ ] && find linux/ -name "*.h" &&
+ [ -d asm/ ] && find asm/ -name "*.h")`)); # XXX this is fragile
+my $basename = "lib/headercheck";
+
+foreach my $h (@headers) {
+ close(STDERR);
+ open(STDERR, ">", "$basename.err");
+
+ open(HC, '>', "$basename.c");
+ print(HC "#include <$h>\n");
+ close(HC);
+
+ # tests
+ if (system("make", "$basename.o") != 0) {
+ print("WARNING: header doesn't build standalone: $h\n");
+ if ($verbose) {
+ system("cat", "$basename.err");
+ }
+ next;
+ }
+
+ my $symbols = `nm $basename.o`;
+ if ($symbols !~ /^$/) {
+ print("WARNING: Symbols may be declared: $h:\n");
+ if ($verbose) {
+ print("$symbols");
+ }
+ }
+} continue {
+ # cleanup
+ unlink("$basename.c");
+ unlink("$basename.err");
+ unlink("$basename.o");
+}
--- linux-2.6.0-test5/Makefile~headercheck 2003-10-01 19:48:46.000000000 +0200
+++ linux-2.6.0-test5/Makefile 2003-10-01 19:53:38.000000000 +0200
@@ -833,6 +833,9 @@
-name '*.[hcS]' -type f -print | sort \
| xargs $(PERL) -w scripts/checkconfig.pl

+headercheck:
+ $(PERL) scripts/checkheader.pl $(if $(KBUILD_VERBOSE),--verbose)
+
includecheck:
find * $(RCS_FIND_IGNORE) \
-name '*.[hcS]' -type f -print | sort \
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.065 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site