3 # checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION
4 # without including <linux/version.h>, or cases of
5 # including <linux/version.h> that don't need it.
6 # Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net>
14 foreach my $file (@ARGV) {
16 open( my $f, '<', $file )
17 or die "Can't open $file: $!\n";
19 # Initialize variables.
20 my ($fInComment, $fInString, $fUseVersion);
21 my $iLinuxVersion = 0;
25 $fInComment && (s
+^.*?\
*/+ +o ?
($fInComment = 0) : next);
26 m
+/\*+o && (s+/\
*.*?\
*/+ +go, (s+/\
*.*$+ +o
&& ($fInComment = 1)));
28 # Pick up definitions.
30 $iLinuxVersion = $. if m/^\s*#\s*include\s*"linux\/version\
.h
"/o;
34 $fInString && (s+^.*?"+ +o ?
($fInString = 0) : next);
35 m
+"+o && (s+".*?
"+ +go, (s+".*$+ +o
&& ($fInString = 1)));
37 # Pick up definitions.
39 $iLinuxVersion = $. if m/^\s*#\s*include\s*<linux\/version\
.h
>/o
;
42 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE
43 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) {
45 last if $iLinuxVersion;
49 # Report used version IDs without include?
50 if ($fUseVersion && ! $iLinuxVersion) {
51 print "$file: $.: need linux/version.h\n";
54 # Report superfluous includes.
55 if ($iLinuxVersion && ! $fUseVersion) {
56 print "$file: $iLinuxVersion linux/version.h not needed.\n";
59 # debug: report OK results:
61 if ($iLinuxVersion && $fUseVersion) {
62 print "$file: version use is OK ($iLinuxVersion)\n";
64 if (! $iLinuxVersion && ! $fUseVersion) {
65 print "$file: version use is OK (none)\n";
This page took 0.03138 seconds and 5 git commands to generate.