export_report: fix perl warnings
Use local file handles, use three argument open. Don't modify arguments in perl grep (use sed instead) Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Acked-by: WANG Cong <amwang@redhat.com> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
This commit is contained in:
parent
9c49fd307a
commit
91416cfdf9
1 changed files with 20 additions and 17 deletions
|
@ -49,10 +49,10 @@ sub usage {
|
|||
}
|
||||
|
||||
sub collectcfiles {
|
||||
my @file = `cat .tmp_versions/*.mod | grep '.*\.ko\$'`;
|
||||
@file = grep {s/\.ko/.mod.c/} @file;
|
||||
chomp @file;
|
||||
return @file;
|
||||
my @file
|
||||
= `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`;
|
||||
chomp @file;
|
||||
return @file;
|
||||
}
|
||||
|
||||
my (%SYMBOL, %MODULE, %opt, @allcfiles);
|
||||
|
@ -71,37 +71,40 @@ if (not defined $opt{'k'}) {
|
|||
$opt{'k'} = "Module.symvers";
|
||||
}
|
||||
|
||||
unless (open(MODULE_SYMVERS, $opt{'k'})) {
|
||||
die "Sorry, cannot open $opt{'k'}: $!\n";
|
||||
}
|
||||
open (my $module_symvers, '<', $opt{'k'})
|
||||
or die "Sorry, cannot open $opt{'k'}: $!\n";
|
||||
|
||||
if (defined $opt{'o'}) {
|
||||
unless (open(OUTPUT_HANDLE, ">$opt{'o'}")) {
|
||||
die "Sorry, cannot open $opt{'o'} $!\n";
|
||||
}
|
||||
select OUTPUT_HANDLE;
|
||||
open (my $out, '>', $opt{'o'})
|
||||
or die "Sorry, cannot open $opt{'o'} $!\n";
|
||||
|
||||
select $out;
|
||||
}
|
||||
|
||||
#
|
||||
# collect all the symbols and their attributes from the
|
||||
# Module.symvers file
|
||||
#
|
||||
while ( <MODULE_SYMVERS> ) {
|
||||
while ( <$module_symvers> ) {
|
||||
chomp;
|
||||
my (undef, $symbol, $module, $gpl) = split;
|
||||
$SYMBOL { $symbol } = [ $module , "0" , $symbol, $gpl];
|
||||
}
|
||||
close(MODULE_SYMVERS);
|
||||
close($module_symvers);
|
||||
|
||||
#
|
||||
# collect the usage count of each symbol.
|
||||
#
|
||||
foreach my $thismod (@allcfiles) {
|
||||
unless (open(MODULE_MODULE, $thismod)) {
|
||||
print "Sorry, cannot open $thismod: $!\n";
|
||||
my $module;
|
||||
|
||||
unless (open ($module, '<', $thismod)) {
|
||||
warn "Sorry, cannot open $thismod: $!\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my $state=0;
|
||||
while ( <MODULE_MODULE> ) {
|
||||
while ( <$module> ) {
|
||||
chomp;
|
||||
if ($state == 0) {
|
||||
$state = 1 if ($_ =~ /static const struct modversion_info/);
|
||||
|
@ -124,7 +127,7 @@ foreach my $thismod (@allcfiles) {
|
|||
if ($state != 2) {
|
||||
print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n";
|
||||
}
|
||||
close(MODULE_MODULE);
|
||||
close($module);
|
||||
}
|
||||
|
||||
print "\tThis file reports the exported symbols usage patterns by in-tree\n",
|
||||
|
|
Loading…
Reference in a new issue