cgroup: Add cgroup_subsys->css_rstat_flush()
[linux/fpc-iii.git] / scripts / checkversion.pl
blobf67b125c5269ed6cd4cdb761396b1db6d237710f
1 #! /usr/bin/env perl
2 # SPDX-License-Identifier: GPL-2.0
4 # checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION
5 # without including <linux/version.h>, or cases of
6 # including <linux/version.h> that don't need it.
7 # Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net>
9 use strict;
11 $| = 1;
13 my $debugging;
15 foreach my $file (@ARGV) {
16 next if $file =~ "include/linux/version\.h";
17 # Open this file.
18 open( my $f, '<', $file )
19 or die "Can't open $file: $!\n";
21 # Initialize variables.
22 my ($fInComment, $fInString, $fUseVersion);
23 my $iLinuxVersion = 0;
25 while (<$f>) {
26 # Strip comments.
27 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
28 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
30 # Pick up definitions.
31 if ( m/^\s*#/o ) {
32 $iLinuxVersion = $. if m/^\s*#\s*include\s*"linux\/version\.h"/o;
35 # Strip strings.
36 $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
37 m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
39 # Pick up definitions.
40 if ( m/^\s*#/o ) {
41 $iLinuxVersion = $. if m/^\s*#\s*include\s*<linux\/version\.h>/o;
44 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE
45 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) {
46 $fUseVersion = 1;
47 last if $iLinuxVersion;
51 # Report used version IDs without include?
52 if ($fUseVersion && ! $iLinuxVersion) {
53 print "$file: $.: need linux/version.h\n";
56 # Report superfluous includes.
57 if ($iLinuxVersion && ! $fUseVersion) {
58 print "$file: $iLinuxVersion linux/version.h not needed.\n";
61 # debug: report OK results:
62 if ($debugging) {
63 if ($iLinuxVersion && $fUseVersion) {
64 print "$file: version use is OK ($iLinuxVersion)\n";
66 if (! $iLinuxVersion && ! $fUseVersion) {
67 print "$file: version use is OK (none)\n";
71 close($f);