mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [announce] checkversion.pl script
@ 2003-08-28  1:05 Randy.Dunlap
  0 siblings, 0 replies; only message in thread
From: Randy.Dunlap @ 2003-08-28  1:05 UTC (permalink / raw)
  To: kj; +Cc: lkml

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

Hi,

I modified scripts/checkconfig.pl to make checkversion.pl.
It checks for cases of <linux/version.h> #included but not
needed (which makes for more rebuilds than required) and for
cases of <linux/version.h> not #included when macros from it
are used.  (Thanks for Randy Hron for some updates to it.)

You can get it from (for future updates; also attached)
  http://developer.osdl.org/rddunlap/scripts/checkversion.pl

Sample from linux-2.6.0-test3, fs/ only:

[rddunlap@dragon fs]$ find . -name \*\.c | xargs checkversion.pl | more
./afs/cmservice.c: 12 linux/version.h not needed.
./afs/kafstimod.c: 12 linux/version.h not needed.
./afs/kafsasyncd.c: 19 linux/version.h not needed.
./cifs/file.c: 26 linux/version.h not needed.
./cifs/transport.c: 26 linux/version.h not needed.
./cifs/cifsfs.c: 31 linux/version.h not needed.
./nls/nls_base.c: 11 linux/version.h not needed.
./jffs2/super.c: 17 linux/version.h not needed.
./jffs2/fs.c: 356: need linux/version.h
./jffs2/file.c: 435: need linux/version.h
./coda/coda_linux.c: 10 linux/version.h not needed.
./adfs/super.c: 10 linux/version.h not needed.
./adfs/dir_fplus.c: 10 linux/version.h not needed.
./adfs/inode.c: 10 linux/version.h not needed.
./adfs/map.c: 10 linux/version.h not needed.
./adfs/dir_f.c: 12 linux/version.h not needed.
./adfs/dir.c: 13 linux/version.h not needed.
./adfs/file.c: 22 linux/version.h not needed.
./udf/super.c: 49 linux/version.h not needed.
./befs/datastream.c: 14 linux/version.h not needed.
./lockd/svc.c: 24 linux/version.h not needed.
./devfs/base.c: 677 linux/version.h not needed.
./jffs/intrep.c: 67 linux/version.h not needed.

--
~Randy

[-- Attachment #2: checkversion.pl --]
[-- Type: application/octet-stream, Size: 1905 bytes --]

#! /usr/bin/perl
#
# checkversion find uses of LINUX_VERSION_CODE, KERNEL_VERSION, or
# UTS_RELEASE without including <linux/version.h>, or cases of
# including <linux/version.h> that don't need it.
# Copyright (C) 2003, Randy Dunlap <rddunlap@osdl.org>

$| = 1;

my $debugging = 0;

foreach $file (@ARGV)
{
    # Open this file.
    open(FILE, $file) || die "Can't open $file: $!\n";

    # 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
	if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/) ||
		($_ =~ /UTS_RELEASE/)) {
	    $fUseVersion = 1;
	    last LINE if $iLinuxVersion;
	}
    }

    # Report used version IDs without include?
    if ($fUseVersion && ! $iLinuxVersion) {
	print "$file: $.: need linux/version.h\n";
    }

    # Report superfluous includes.
    if ($iLinuxVersion && ! $fUseVersion) {
	print "$file: $iLinuxVersion linux/version.h not needed.\n";
    }

    # debug: report OK results:
    if ($debugging) {
        if ($iLinuxVersion && $fUseVersion) {
	    print "$file: version use is OK ($iLinuxVersion)\n";
        }
        if (! $iLinuxVersion && ! $fUseVersion) {
	    print "$file: version use is OK (none)\n";
        }
    }

    close(FILE);
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-08-28  1:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-28  1:05 [announce] checkversion.pl script Randy.Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®