History

export_report: fix perl warnings

Use local file handles, use three argument open. Don't modify arguments in perl grep (use sed instead)

Stephen Hemminger committed 16 years ago

Commit 91416cf1 parent 9c49fd31 file · +20 −17Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/export_report.pl+20−17
@@ -49,10 +49,10 @@ sub usage { · 48 unmodified lines
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 @@ if (not defined $opt{'k'}) { · 12 unmodified lines
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 @@ foreach my $thismod (@allcfiles) { · 16 unmodified lines
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",