lkml.org 
[lkml]   [2003]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] check headers for complete includes, etc.
On Sun, 28 September 2003 21:44:31 +0200, Jörn Engel wrote:
> On Sun, 28 September 2003 21:31:50 +0200, Sam Ravnborg wrote:
> >
> > That should do it. Can you also integrate the check Linus mentioned,
> > to make sure no declarations are present.
>
> If it's simple enough, you'll have it tomorrow. Linus' check might
> take a bit longer, I'm not sure yet how to define an empty object
> file. Is it enough if objdump -tT only shows sections?
>
> > I would name the target: headercheck:
> > to be consistent with the other targets.
>
> ok.

First version of the script. Seems to work, but it catches a lot,
maybe too much.

Jörn

--
"Error protection by error detection and correction."
-- from a university class

--- /dev/null 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-test5/scripts/checkheader.pl 2003-09-29 15:33:10.000000000 +0200
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+use strict;
+
+my $normsymbols = "^\n"
+ . "lib/header.o: file format elf32-i386\n"
+ . "\n"
+ . "SYMBOL TABLE:\n"
+ . "00000000 l df \\*ABS\\* 00000000 header.c\n"
+ . "00000000 l d .text 00000000 \n"
+ . "00000000 l d .data 00000000 \n"
+ . "00000000 l d .bss 00000000 \n"
+ . "00000000 l d .comment 00000000 \n"
+ . "\n"
+ . "\n\$";
+
+#my @headers = ("linux/fs.h");
+my @headers = sort(split(/\n/, `(cd include/ && find linux -name "*.h")`));
+my $basename = "lib/header";
+
+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");
+ next;
+ }
+
+ my $symbols = `objdump -t $basename.o`;
+ if ($symbols !~ /$normsymbols/) {
+ print("WARNING: Symbols may be declared: $h\n");
+ }
+} continue {
+ # cleanup
+ unlink("$basename.c");
+ unlink("$basename.err");
+ unlink("$basename.o");
+}
--- linux-2.6.0-test5/Makefile~headercheck 2003-09-28 21:37:19.000000000 +0200
+++ linux-2.6.0-test5/Makefile 2003-09-29 15:31:13.000000000 +0200
@@ -838,6 +838,9 @@
-name '*.[hcS]' -type f -print | sort \
| xargs $(PERL) -w scripts/checkincludes.pl

+headercheck:
+ $(PERL) scripts/checkheader.pl
+
versioncheck:
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:48    [W:0.155 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site