Blame view
scripts/checkversion.pl
1.82 KB
1da177e4c
|
1 2 |
#! /usr/bin/perl # |
63104eec2
|
3 4 |
# checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION # without including <linux/version.h>, or cases of |
1da177e4c
|
5 |
# including <linux/version.h> that don't need it. |
f4b09ebc8
|
6 |
# Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net> |
1da177e4c
|
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
$| = 1; my $debugging = 0; foreach $file (@ARGV) { # Open this file. open(FILE, $file) || die "Can't open $file: $! "; # Initialize variables. my $fInComment = 0; my $fInString = 0; my $fUseVersion = 0; my $iLinuxVersion = 0; LINE: while ( <FILE> ) { # 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
|
45 |
if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) { |
1da177e4c
|
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 71 72 73 74 75 76 |
$fUseVersion = 1; last LINE if $iLinuxVersion; } } # 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) "; } } close(FILE); } |