~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/usr/include/headers_check.pl

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /usr/include/headers_check.pl (Version linux-6.12-rc7) and /usr/include/headers_check.pl (Version linux-5.7.19)


  1 #!/usr/bin/env perl                               
  2 # SPDX-License-Identifier: GPL-2.0                
  3 #                                                 
  4 # headers_check.pl execute a number of trivial    
  5 #                                                 
  6 # Usage: headers_check.pl dir arch [files...]     
  7 # dir:   dir to look for included files           
  8 # arch:  architecture                             
  9 # files: list of files to check                   
 10 #                                                 
 11 # The script reads the supplied files line by     
 12 #                                                 
 13 # 1) for each include statement it checks if t    
 14 #    included file actually exists.               
 15 #    Only include files located in asm* and li    
 16 #    The rest are assumed to be system include    
 17 #                                                 
 18 # 2) It is checked that prototypes does not us    
 19 #                                                 
 20 # 3) Check for leaked CONFIG_ symbols             
 21                                                   
 22 use warnings;                                     
 23 use strict;                                       
 24 use File::Basename;                               
 25                                                   
 26 my ($dir, $arch, @files) = @ARGV;                 
 27                                                   
 28 my $ret = 0;                                      
 29 my $line;                                         
 30 my $lineno = 0;                                   
 31 my $filename;                                     
 32                                                   
 33 foreach my $file (@files) {                       
 34         $filename = $file;                        
 35                                                   
 36         open(my $fh, '<', $filename)              
 37                 or die "$filename: $!\n";         
 38         $lineno = 0;                              
 39         while ($line = <$fh>) {                   
 40                 $lineno++;                        
 41                 &check_include();                 
 42                 &check_asm_types();               
 43                 &check_sizetypes();               
 44                 &check_declarations();            
 45                 # Dropped for now. Too much no    
 46         }                                         
 47         close $fh;                                
 48 }                                                 
 49 exit $ret;                                        
 50                                                   
 51 sub check_include                                 
 52 {                                                 
 53         if ($line =~ m/^\s*#\s*include\s+<((as    
 54                 my $inc = $1;                     
 55                 my $found;                        
 56                 $found = stat($dir . "/" . $in    
 57                 if (!$found) {                    
 58                         $inc =~ s#asm/#asm-$ar    
 59                         $found = stat($dir . "    
 60                 }                                 
 61                 if (!$found) {                    
 62                         printf STDERR "$filena    
 63                         $ret = 1;                 
 64                 }                                 
 65         }                                         
 66 }                                                 
 67                                                   
 68 sub check_declarations                            
 69 {                                                 
 70         # soundcard.h is what it is               
 71         if ($line =~ m/^void seqbuf_dump\(void    
 72                 return;                           
 73         }                                         
 74         # drm headers are being C++ friendly      
 75         if ($line =~ m/^extern "C"/) {            
 76                 return;                           
 77         }                                         
 78         if ($line =~ m/^(\s*extern|unsigned|ch    
 79                 printf STDERR "$filename:$line    
 80                               "userspace canno    
 81                               "variable define    
 82         }                                         
 83 }                                                 
 84                                                   
 85 sub check_config                                  
 86 {                                                 
 87         if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([    
 88                 printf STDERR "$filename:$line    
 89         }                                         
 90 }                                                 
 91                                                   
 92 my $linux_asm_types;                              
 93 sub check_asm_types                               
 94 {                                                 
 95         if ($filename =~ /types.h|int-l64.h|in    
 96                 return;                           
 97         }                                         
 98         if ($lineno == 1) {                       
 99                 $linux_asm_types = 0;             
100         } elsif ($linux_asm_types >= 1) {         
101                 return;                           
102         }                                         
103         if ($line =~ m/^\s*#\s*include\s+<asm\    
104                 $linux_asm_types = 1;             
105                 printf STDERR "$filename:$line    
106                 "include of <linux/types.h> is    
107                 # Warn until headers are all f    
108                 #$ret = 1;                        
109         }                                         
110 }                                                 
111                                                   
112 my $linux_types;                                  
113 my %import_stack = ();                            
114 sub check_include_typesh                          
115 {                                                 
116         my $path = $_[0];                         
117         my $import_path;                          
118                                                   
119         my $fh;                                   
120         my @file_paths = ($path, $dir . "/" .     
121         for my $possible ( @file_paths ) {        
122             if (not $import_stack{$possible} a    
123                 $import_path = $possible;         
124                 $import_stack{$import_path} =     
125                 last;                             
126             }                                     
127         }                                         
128         if (eof $fh) {                            
129             return;                               
130         }                                         
131                                                   
132         my $line;                                 
133         while ($line = <$fh>) {                   
134                 if ($line =~ m/^\s*#\s*include    
135                         $linux_types = 1;         
136                         last;                     
137                 }                                 
138                 if (my $included = ($line =~ /    
139                         check_include_typesh($    
140                 }                                 
141         }                                         
142         close $fh;                                
143         delete $import_stack{$import_path};       
144 }                                                 
145                                                   
146 sub check_sizetypes                               
147 {                                                 
148         if ($filename =~ /types.h|int-l64.h|in    
149                 return;                           
150         }                                         
151         if ($lineno == 1) {                       
152                 $linux_types = 0;                 
153         } elsif ($linux_types >= 1) {             
154                 return;                           
155         }                                         
156         if ($line =~ m/^\s*#\s*include\s+<linu    
157                 $linux_types = 1;                 
158                 return;                           
159         }                                         
160         if (my $included = ($line =~ /^\s*#\s*    
161                 check_include_typesh($included    
162         }                                         
163         if ($line =~ m/__[us](8|16|32|64)\b/)     
164                 printf STDERR "$filename:$line    
165                               "found __[us]{8,    
166                               "without #includ    
167                 $linux_types = 2;                 
168                 # Warn until headers are all f    
169                 #$ret = 1;                        
170         }                                         
171 }                                                 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php