aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/headers_check.pl
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-27 12:59:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-27 12:59:59 -0400
commit6948385cbd83201fb933125c1a578b29b456605d (patch)
treefd08f30c84d02cfb1ad696d04605565974fae7be /scripts/headers_check.pl
parent7a76d89232f20411f32e7a79ccc1e2f95e9f826b (diff)
parent56b2f0706d82535fd8d85503f2dcc0be40c8e55d (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next: (25 commits) setlocalversion: do not describe if there is nothing to describe kconfig: fix typos: "Suport" -> "Support" kconfig: make defconfig is no longer chatty kconfig: make oldconfig is now less chatty kconfig: speed up all*config + randconfig kconfig: set all new symbols automatically kconfig: add diffconfig utility kbuild: remove Module.markers during mrproper kbuild: sparse needs CF not CHECKFLAGS kernel-doc: handle/strip __init vmlinux.lds: move __attribute__((__cold__)) functions back into final .text section init: fix URL of "The GNU Accounting Utilities" kbuild: add arch/$ARCH/include to search path kbuild: asm symlink support for arch/$ARCH/include kbuild: support arch/$ARCH/include for tags, cscope kbuild: prepare headers_* for arch/$ARCH/include kbuild: install all headers when arch is changed kbuild: make clean removes *.o.* as well kbuild: optimize headers_* targets kbuild: only one call for include/ in make headers_* ...
Diffstat (limited to 'scripts/headers_check.pl')
-rw-r--r--scripts/headers_check.pl56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
new file mode 100644
index 000000000000..15d53a6b1a1f
--- /dev/null
+++ b/scripts/headers_check.pl
@@ -0,0 +1,56 @@
1#!/usr/bin/perl
2#
3# headers_check.pl execute a number of trivial consistency checks
4#
5# Usage: headers_check.pl dir [files...]
6# dir: dir to look for included files
7# arch: architecture
8# files: list of files to check
9#
10# The script reads the supplied files line by line and:
11#
12# 1) for each include statement it checks if the
13# included file actually exists.
14# Only include files located in asm* and linux* are checked.
15# The rest are assumed to be system include files.
16#
17# 2) TODO: check for leaked CONFIG_ symbols
18
19use strict;
20use warnings;
21
22my ($dir, $arch, @files) = @ARGV;
23
24my $ret = 0;
25my $line;
26my $lineno = 0;
27my $filename;
28
29foreach my $file (@files) {
30 $filename = $file;
31 open(my $fh, '<', "$filename") or die "$filename: $!\n";
32 $lineno = 0;
33 while ($line = <$fh>) {
34 $lineno++;
35 check_include();
36 }
37 close $fh;
38}
39exit $ret;
40
41sub check_include
42{
43 if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
44 my $inc = $1;
45 my $found;
46 $found = stat($dir . "/" . $inc);
47 if (!$found) {
48 $inc =~ s#asm/#asm-$arch/#;
49 $found = stat($dir . "/" . $inc);
50 }
51 if (!$found) {
52 printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
53 $ret = 1;
54 }
55 }
56}