diff options
| author | Bobby Powers <bobbypowers@gmail.com> | 2012-03-05 18:08:09 -0500 |
|---|---|---|
| committer | Michal Marek <mmarek@suse.cz> | 2012-03-26 08:54:27 -0400 |
| commit | f75a8df3bd6466e29a4e40b86b2cfc96fe06d328 (patch) | |
| tree | b9972a299bac56b5483e4fe3ef76cad1630d3ff5 /scripts | |
| parent | 875de98623fa2b29f0cb19915fe3292ab6daa1cb (diff) | |
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.
Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Dave Airlie <airlied@linux.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/headers_check.pl | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl index 7957e7a5166..64ac2380e4d 100644 --- a/scripts/headers_check.pl +++ b/scripts/headers_check.pl | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | # 3) Check for leaked CONFIG_ symbols | 19 | # 3) Check for leaked CONFIG_ symbols |
| 20 | 20 | ||
| 21 | use strict; | 21 | use strict; |
| 22 | use File::Basename; | ||
| 22 | 23 | ||
| 23 | my ($dir, $arch, @files) = @ARGV; | 24 | my ($dir, $arch, @files) = @ARGV; |
| 24 | 25 | ||
| @@ -99,6 +100,39 @@ sub check_asm_types | |||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | my $linux_types; | 102 | 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 | |||
| 102 | sub check_sizetypes | 136 | sub check_sizetypes |
| 103 | { | 137 | { |
| 104 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { | 138 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { |
| @@ -113,6 +147,9 @@ sub check_sizetypes | |||
| 113 | $linux_types = 1; | 147 | $linux_types = 1; |
| 114 | return; | 148 | return; |
| 115 | } | 149 | } |
| 150 | if (my $included = ($line =~ /^\s*#\s*include\s+[<"](\S+)[>"]/)[0]) { | ||
| 151 | check_include_typesh($included); | ||
| 152 | } | ||
| 116 | if ($line =~ m/__[us](8|16|32|64)\b/) { | 153 | if ($line =~ m/__[us](8|16|32|64)\b/) { |
| 117 | printf STDERR "$filename:$lineno: " . | 154 | printf STDERR "$filename:$lineno: " . |
| 118 | "found __[us]{8,16,32,64} type " . | 155 | "found __[us]{8,16,32,64} type " . |
| @@ -122,4 +159,3 @@ sub check_sizetypes | |||
| 122 | #$ret = 1; | 159 | #$ret = 1; |
| 123 | } | 160 | } |
| 124 | } | 161 | } |
| 125 | |||
