Commit 6088e9ffa29a92e7b80fdba44929f3225c4c0357

Authored by Peter Foley
Committed by Michal Marek
1 parent 177525d26e

kbuild: don't warn about include/linux/version.h not including itself

This patch makes checkversion.pl not warn that include/linux/version.h
dosen't include itself.

Signed-off-by: Peter Foley <pefoley2@verizon.net>
[mmarek: simplified to use 'next if' syntax]
Signed-off-by: Michal Marek <mmarek@suse.cz>

Showing 1 changed file with 1 additions and 0 deletions Inline Diff

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