aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2008-12-30 05:34:58 -0500
committerSam Ravnborg <sam@ravnborg.org>2009-01-02 14:43:26 -0500
commit483b41218fa9d5172312a9e294aaf78e22b266e6 (patch)
tree03c10a53e3b9a35b9bab8e4d81b35e0a086a873a /scripts
parent521b0c774d1350aac18f5cd35831469a4e879d72 (diff)
kbuild: add checks for include of linux/types in userspace headers
If we see __[us](8|16|32|64) then we must include <linux/types.h> If wee see include of <asm/types.h> then we recommend <linux/types.h> Original script from Mike but modified by me. Cc: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/headers_check.pl47
1 files changed, 44 insertions, 3 deletions
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 72924a7fcf1e..b62c319611a2 100644
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -34,9 +34,11 @@ foreach my $file (@files) {
34 $lineno = 0; 34 $lineno = 0;
35 while ($line = <FH>) { 35 while ($line = <FH>) {
36 $lineno++; 36 $lineno++;
37 check_include(); 37 &check_include();
38 check_prototypes(); 38 &check_asm_types();
39 check_config(); 39 &check_sizetypes();
40 &check_prototypes();
41 &check_config();
40 } 42 }
41 close FH; 43 close FH;
42} 44}
@@ -73,3 +75,42 @@ sub check_config
73 } 75 }
74} 76}
75 77
78my $linux_asm_types;
79sub check_asm_types()
80{
81 if ($lineno == 1) {
82 $linux_asm_types = 0;
83 } elsif ($linux_asm_types >= 1) {
84 return;
85 }
86 if ($line =~ m/^\s*#\s*include\s+<asm\/types.h>/) {
87 $linux_asm_types = 1;
88 printf STDERR "$filename:$lineno: " .
89 "include of <linux/types.h> is preferred over <asm/types.h>\n"
90 # Warn until headers are all fixed
91 #$ret = 1;
92 }
93}
94
95my $linux_types;
96sub check_sizetypes
97{
98 if ($lineno == 1) {
99 $linux_types = 0;
100 } elsif ($linux_types >= 1) {
101 return;
102 }
103 if ($line =~ m/^\s*#\s*include\s+<linux\/types.h>/) {
104 $linux_types = 1;
105 return;
106 }
107 if ($line =~ m/__[us](8|16|32|64)\b/) {
108 printf STDERR "$filename:$lineno: " .
109 "found __[us]{8,16,32,64} type " .
110 "without #include <linux/types.h>\n";
111 $linux_types = 2;
112 # Warn until headers are all fixed
113 #$ret = 1;
114 }
115}
116