memory: memory notifier error injection module
[linux/fpc-iii.git] / scripts / checkversion.pl
blob5e490a8ceca5582e3003890cf34a21c33447969f
1 #! /usr/bin/perl
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>
8 use strict;
10 $| = 1;
12 my $debugging;
14 foreach my $file (@ARGV) {
15 next if $file =~ "include/linux/version\.h";
16 # Open this file.
17 open( my $f, '<', $file )
18 or die "Can't open $file: $!\n";
20 # Initialize variables.
21 my ($fInComment, $fInString, $fUseVersion);
22 my $iLinuxVersion = 0;
24 while (<$f>) {
25 # Strip comments.
26 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
27 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
29 # Pick up definitions.
30 if ( m/^\s*#/o ) {
31 $iLinuxVersion = $. if m/^\s*#\s*include\s*"linux\/version\.h"/o;
34 # Strip strings.
35 $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
36 m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
38 # Pick up definitions.
39 if ( m/^\s*#/o ) {
40 $iLinuxVersion = $. if m/^\s*#\s*include\s*<linux\/version\.h>/o;
43 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE
44 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) {
45 $fUseVersion = 1;
46 last if $iLinuxVersion;
50 # Report used version IDs without include?
51 if ($fUseVersion && ! $iLinuxVersion) {
52 print "$file: $.: need linux/version.h\n";
55 # Report superfluous includes.
56 if ($iLinuxVersion && ! $fUseVersion) {
57 print "$file: $iLinuxVersion linux/version.h not needed.\n";
60 # debug: report OK results:
61 if ($debugging) {
62 if ($iLinuxVersion && $fUseVersion) {
63 print "$file: version use is OK ($iLinuxVersion)\n";
65 if (! $iLinuxVersion && ! $fUseVersion) {
66 print "$file: version use is OK (none)\n";
70 close($f);