Archived
14
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/scripts/headers_check.pl
Jeremy Huntwork 15a2ee74d2 Fix incompatibility with versions of Perl less than 5.6.0
Fix headers_install.pl and headers_check.pl to be compatible with versions
of Perl less than 5.6.0.  It has been tested with Perl 5.005_03 and 5.8.8.
I realize this may not be an issue for most people, but there will still
be some that hit it, I imagine.  There are three basic issues:

1. Prior to 5.6.0 open() only used 2 arguments, and the versions of
the scripts in 2.6.27.1 use 3.
2. 5.6.0 also introduced the ability to use uninitialized scalar
variables as file handles, which the current scripts make use of.
3. Lastly, 5.6.0 also introduced the pragma 'use warnings'. We can use
the -w switch and be backwards compatible.

Signed-off-by: Jeremy Huntwork <jhuntwork@lightcubesolutions.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2008-10-29 22:38:37 +01:00

57 lines
1.2 KiB
Perl

#!/usr/bin/perl -w
#
# headers_check.pl execute a number of trivial consistency checks
#
# Usage: headers_check.pl dir [files...]
# dir: dir to look for included files
# arch: architecture
# files: list of files to check
#
# The script reads the supplied files line by line and:
#
# 1) for each include statement it checks if the
# included file actually exists.
# Only include files located in asm* and linux* are checked.
# The rest are assumed to be system include files.
#
# 2) TODO: check for leaked CONFIG_ symbols
use strict;
my ($dir, $arch, @files) = @ARGV;
my $ret = 0;
my $line;
my $lineno = 0;
my $filename;
foreach my $file (@files) {
local *FH;
$filename = $file;
open(FH, "<$filename") or die "$filename: $!\n";
$lineno = 0;
while ($line = <FH>) {
$lineno++;
check_include();
}
close FH;
}
exit $ret;
sub check_include
{
if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
my $inc = $1;
my $found;
$found = stat($dir . "/" . $inc);
if (!$found) {
$inc =~ s#asm/#asm-$arch/#;
$found = stat($dir . "/" . $inc);
}
if (!$found) {
printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
$ret = 1;
}
}
}