3 # headers_check.pl execute a number of trivial consistency checks
5 # Usage: headers_check.pl dir arch [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(my $fh, '<', $filename)
34 or die "$filename: $!\n";
36 while ($line = <$fh>) {
41 &check_declarations
();
42 # Dropped for now. Too much noise &check_config();
50 if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
53 $found = stat($dir . "/" . $inc);
55 $inc =~ s
#asm/#asm-$arch/#;
56 $found = stat($dir . "/" . $inc);
59 printf STDERR
"$filename:$lineno: included file '$inc' is not exported\n";
65 sub check_declarations
67 if ($line =~m/^\s*extern\b/) {
68 printf STDERR
"$filename:$lineno: " .
69 "userspace cannot call function or variable " .
70 "defined in the kernel\n";
76 if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
77 printf STDERR
"$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
84 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) {
89 } elsif ($linux_asm_types >= 1) {
92 if ($line =~ m/^\s*#\s*include\s+<asm\/types
.h
>/) {
94 printf STDERR
"$filename:$lineno: " .
95 "include of <linux/types.h> is preferred over <asm/types.h>\n"
96 # Warn until headers are all fixed
104 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) {
109 } elsif ($linux_types >= 1) {
112 if ($line =~ m/^\s*#\s*include\s+<linux\/types
.h
>/) {
116 if ($line =~ m/__[us](8|16|32|64)\b/) {
117 printf STDERR
"$filename:$lineno: " .
118 "found __[us]{8,16,32,64} type " .
119 "without #include <linux/types.h>\n";
121 # Warn until headers are all fixed
This page took 0.034469 seconds and 5 git commands to generate.