3 # headers_check.pl execute a number of trivial consistency checks
5 # Usage: headers_check.pl dir [files...]
6 # dir: dir to look for included files
8 # files: list of files to check
10 # The script reads the supplied files line by line and:
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.
17 # 2) It is checked that prototypes does not use "extern"
19 # 3) Check for leaked CONFIG_ symbols
23 my ($dir, $arch, @files) = @ARGV;
30 foreach my $file (@files) {
33 open(FH, "<$filename") or die "$filename: $!\n";
35 while ($line = <FH>) {
47 if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
50 $found = stat($dir . "/" . $inc);
52 $inc =~ s#asm/#asm-$arch/#;
53 $found = stat($dir . "/" . $inc);
56 printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
64 if ($line =~ m/^\s*extern\b/) {
65 printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
71 if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9]+)[^a-zA-Z0-9]/) {
72 printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";