Skip to content

Commit 91416cf

Browse files
Stephen Hemmingermichal42
authored andcommitted
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>
1 parent 9c49fd3 commit 91416cf

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

‎scripts/export_report.pl‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ sub usage {
4949
}
5050

5151
sub collectcfiles {
52-
my @file = `cat .tmp_versions/*.mod | grep '.*\.ko\$'`;
53-
@file = grep {s/\.ko/.mod.c/} @file;
54-
chomp @file;
55-
return @file;
52+
my @file
53+
= `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`;
54+
chomp @file;
55+
return @file;
5656
}
5757

5858
my (%SYMBOL, %MODULE, %opt, @allcfiles);
@@ -71,37 +71,40 @@ sub collectcfiles {
7171
$opt{'k'} = "Module.symvers";
7272
}
7373

74-
unless (open(MODULE_SYMVERS, $opt{'k'})) {
75-
die "Sorry, cannot open $opt{'k'}: $!\n";
76-
}
74+
open (my $module_symvers, '<', $opt{'k'})
75+
or die "Sorry, cannot open $opt{'k'}: $!\n";
7776

7877
if (defined $opt{'o'}) {
79-
unless (open(OUTPUT_HANDLE, ">$opt{'o'}")) {
80-
die "Sorry, cannot open $opt{'o'} $!\n";
81-
}
82-
select OUTPUT_HANDLE;
78+
open (my $out, '>', $opt{'o'})
79+
or die "Sorry, cannot open $opt{'o'} $!\n";
80+
81+
select $out;
8382
}
83+
8484
#
8585
# collect all the symbols and their attributes from the
8686
# Module.symvers file
8787
#
88-
while ( <MODULE_SYMVERS> ) {
88+
while ( <$module_symvers> ) {
8989
chomp;
9090
my (undef, $symbol, $module, $gpl) = split;
9191
$SYMBOL { $symbol } = [ $module , "0" , $symbol, $gpl];
9292
}
93-
close(MODULE_SYMVERS);
93+
close($module_symvers);
9494

9595
#
9696
# collect the usage count of each symbol.
9797
#
9898
foreach my $thismod (@allcfiles) {
99-
unless (open(MODULE_MODULE, $thismod)) {
100-
print "Sorry, cannot open $thismod: $!\n";
99+
my $module;
100+
101+
unless (open ($module, '<', $thismod)) {
102+
warn "Sorry, cannot open $thismod: $!\n";
101103
next;
102104
}
105+
103106
my $state=0;
104-
while ( <MODULE_MODULE> ) {
107+
while ( <$module> ) {
105108
chomp;
106109
if ($state == 0) {
107110
$state = 1 if ($_ =~ /static const struct modversion_info/);
@@ -124,7 +127,7 @@ sub collectcfiles {
124127
if ($state != 2) {
125128
print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n";
126129
}
127-
close(MODULE_MODULE);
130+
close($module);
128131
}
129132
130133
print "\tThis file reports the exported symbols usage patterns by in-tree\n",

0 commit comments

Comments
 (0)