Blame view
scripts/checkversion.pl
1.86 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 |
#! /usr/bin/perl # |
63104eec2 kbuild: introduce... |
3 4 |
# checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION # without including <linux/version.h>, or cases of |
1da177e4c Linux-2.6.12-rc2 |
5 |
# including <linux/version.h> that don't need it. |
f4b09ebc8 update the email ... |
6 |
# Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net> |
1da177e4c Linux-2.6.12-rc2 |
7 |
|
a208868fc checkversion: per... |
8 |
use strict; |
1da177e4c Linux-2.6.12-rc2 |
9 |
$| = 1; |
a208868fc checkversion: per... |
10 |
my $debugging; |
1da177e4c Linux-2.6.12-rc2 |
11 |
|
a208868fc checkversion: per... |
12 |
foreach my $file (@ARGV) { |
6088e9ffa kbuild: don't war... |
13 |
next if $file =~ "include/linux/version\.h"; |
1da177e4c Linux-2.6.12-rc2 |
14 |
# Open this file. |
a208868fc checkversion: per... |
15 16 17 |
open( my $f, '<', $file ) or die "Can't open $file: $! "; |
1da177e4c Linux-2.6.12-rc2 |
18 19 |
# Initialize variables. |
a208868fc checkversion: per... |
20 |
my ($fInComment, $fInString, $fUseVersion); |
1da177e4c Linux-2.6.12-rc2 |
21 |
my $iLinuxVersion = 0; |
a208868fc checkversion: per... |
22 |
while (<$f>) { |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# Strip comments. $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next); m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1))); # Pick up definitions. if ( m/^\s*#/o ) { $iLinuxVersion = $. if m/^\s*#\s*include\s*"linux\/version\.h"/o; } # Strip strings. $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next); m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1))); # Pick up definitions. if ( m/^\s*#/o ) { $iLinuxVersion = $. if m/^\s*#\s*include\s*<linux\/version\.h>/o; } # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE |
63104eec2 kbuild: introduce... |
42 |
if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) { |
1da177e4c Linux-2.6.12-rc2 |
43 |
$fUseVersion = 1; |
a208868fc checkversion: per... |
44 45 |
last if $iLinuxVersion; } |
1da177e4c Linux-2.6.12-rc2 |
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
} # Report used version IDs without include? if ($fUseVersion && ! $iLinuxVersion) { print "$file: $.: need linux/version.h "; } # Report superfluous includes. if ($iLinuxVersion && ! $fUseVersion) { print "$file: $iLinuxVersion linux/version.h not needed. "; } # debug: report OK results: if ($debugging) { if ($iLinuxVersion && $fUseVersion) { print "$file: version use is OK ($iLinuxVersion) "; } if (! $iLinuxVersion && ! $fUseVersion) { print "$file: version use is OK (none) "; } } |
a208868fc checkversion: per... |
71 |
close($f); |
1da177e4c Linux-2.6.12-rc2 |
72 |
} |