Skip to content

Commit

Permalink
export_report: fix perl warnings
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Hemminger authored and michal42 committed Mar 7, 2010
1 parent 9c49fd3 commit 91416cf
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions scripts/export_report.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -71,37 +71,40 @@ sub collectcfiles {
$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/);
Expand All @@ -124,7 +127,7 @@ sub collectcfiles {
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",
Expand Down

0 comments on commit 91416cf

Please sign in to comment.