History

headers_check: recursively search for linux/types.h inclusion

headers_check.pl currently emits some spurious warnings, especially for the drm headers, about using __[us]{8,16,32,64} types without including linux/types.h. Recursively search for types.h inclusion, avoiding circular references.

Bobby Powers committed 14 years ago

Commit f75a8df1 parent 875de981 file · +37 −1Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/headers_check.pl+37−1
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 # 3) Check for leaked CONFIG_ symbols
2020
2121 use strict;
22+use File::Basename;
2223
2324 my ($dir, $arch, @files) = @ARGV;
2425
@@ -99,6 +100,39 @@ sub check_asm_types · 74 unmodified lines
99100 }
100101
101102 my $linux_types;
103+my %import_stack = ();
104+sub check_include_typesh
105+{
106+ my $path = $_[0];
107+ my $import_path;
108+
109+ my $fh;
110+ my @file_paths = ($path, $dir . "/" . $path, dirname($filename) . "/" . $path);
111+ for my $possible ( @file_paths ) {
112+ if (not $import_stack{$possible} and open($fh, '<', $possible)) {
113+ $import_path = $possible;
114+ $import_stack{$import_path} = 1;
115+ last;
116+ }
117+ }
118+ if (eof $fh) {
119+ return;
120+ }
121+
122+ my $line;
123+ while ($line = <$fh>) {
124+ if ($line =~ m/^\s*#\s*include\s+<linux\/types.h>/) {
125+ $linux_types = 1;
126+ last;
127+ }
128+ if (my $included = ($line =~ /^\s*#\s*include\s+[<"](\S+)[>"]/)[0]) {
129+ check_include_typesh($included);
130+ }
131+ }
132+ close $fh;
133+ delete $import_stack{$import_path};
134+}
135+
102136 sub check_sizetypes
103137 {
104138 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) {
@@ -113,6 +147,9 @@ sub check_sizetypes · 8 unmodified lines
113147 $linux_types = 1;
114148 return;
115149 }
150+ if (my $included = ($line =~ /^\s*#\s*include\s+[<"](\S+)[>"]/)[0]) {
151+ check_include_typesh($included);
152+ }
116153 if ($line =~ m/__[us](8|16|32|64)\b/) {
117154 printf STDERR "$filename:$lineno: " .
118155 "found __[us]{8,16,32,64} type " .
@@ -122,4 +159,3 @@ sub check_sizetypes · 3 unmodified lines
122159 #$ret = 1;
123160 }
124161 }
125−