mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rddunlap@osdl.org>
To: kj <kernel-janitor-discuss@lists.sourceforge.net>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [announce] checkversion.pl script
Date: Wed, 27 Aug 2003 18:05:27 -0700	[thread overview]
Message-ID: <20030827180527.509ae6b4.rddunlap@osdl.org> (raw)

[-- 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);
}

                 reply	other threads:[~2003-08-28  1:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030827180527.509ae6b4.rddunlap@osdl.org \
    --to=rddunlap@osdl.org \
    --cc=kernel-janitor-discuss@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®