linux-old/scripts/checkconfig.pl
<<
>>
Prefs
   1#! /usr/bin/perl
   2#
   3# checkconfig: find uses of CONFIG_* names without matching definitions.
   4# Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
   5
   6use integer;
   7
   8$| = 1;
   9
  10foreach $file (@ARGV)
  11{
  12    # Open this file.
  13    open(FILE, $file) || die "Can't open $file: $!\n";
  14
  15    # Initialize variables.
  16    my $fInComment   = 0;
  17    my $fUseConfig   = 0;
  18    my $iLinuxConfig = 0;
  19    my %configList   = ();
  20
  21    LINE: while ( <FILE> )
  22    {
  23        # Strip comments.
  24        $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
  25        m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
  26
  27        # Pick up definitions.
  28        if ( m/^#/o )
  29        {
  30            $iLinuxConfig      = $. if m/^#\s*include\s*<linux\/config\.h>/o;
  31            $configList{uc $1} = 1  if m/^#\s*include\s*<config\/(\S*)\.h>/o;
  32            $configList{$1}    = 1  if m/^#\s*define\s+CONFIG_(\w*)/o;
  33            $configList{$1}    = 1  if m/^#\s*undef\s+CONFIG_(\w*)/o;
  34        }
  35
  36        # Look for usages.
  37        next unless m/CONFIG_/o;
  38        WORD: while ( m/\bCONFIG_(\w+)/og )
  39        {
  40            $fUseConfig = 1;
  41            last LINE if $iLinuxConfig;
  42            next WORD if exists $configList{$1};
  43            print "$file: $.: need CONFIG_$1.\n";
  44            $configList{$1} = 0;
  45        }
  46    }
  47
  48    # Report superfluous includes.
  49    if ( $iLinuxConfig && ! $fUseConfig )
  50        { print "$file: $iLinuxConfig: <linux/config.h> not needed.\n"; }
  51
  52    close(FILE);
  53}
  54
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.