0001
0002
0003
0004
0005
0006
0007
0008
0009 use strict;
0010
0011 $| = 1;
0012
0013 my $debugging;
0014
0015 foreach my $file (@ARGV) {
0016 next if $file =~ "include/generated/uapi/linux/version\.h";
0017 next if $file =~ "usr/include/linux/version\.h";
0018
0019 open( my $f, '<', $file )
0020 or die "Can't open $file: $!\n";
0021
0022
0023 my ($fInComment, $fInString, $fUseVersion);
0024 my $iLinuxVersion = 0;
0025
0026 while (<$f>) {
0027
0028 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
0029 && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
0030
0031
0032 if ( ) {
0033 $iLinuxVersion = $. if ;
0034 }
0035
0036
0037 $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
0038 && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
0039
0040
0041 if ( ) {
0042 $iLinuxVersion = $. if ;
0043 }
0044
0045
0046
0047 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/) ||
0048 ($_ =~ /LINUX_VERSION_MAJOR/) || ($_ =~ /LINUX_VERSION_PATCHLEVEL/) ||
0049 ($_ =~ /LINUX_VERSION_SUBLEVEL/)) {
0050 $fUseVersion = 1;
0051 last if $iLinuxVersion;
0052 }
0053 }
0054
0055
0056 if ($fUseVersion && ! $iLinuxVersion) {
0057 print "$file: $.: need linux/version.h\n";
0058 }
0059
0060
0061 if ($iLinuxVersion && ! $fUseVersion) {
0062 print "$file: $iLinuxVersion linux/version.h not needed.\n";
0063 }
0064
0065
0066 if ($debugging) {
0067 if ($iLinuxVersion && $fUseVersion) {
0068 print "$file: version use is OK ($iLinuxVersion)\n";
0069 }
0070 if (! $iLinuxVersion && ! $fUseVersion) {
0071 print "$file: version use is OK (none)\n";
0072 }
0073 }
0074
0075 close($f);
0076 }