Use local file handle not global. Make loop and other variables local in scope.
Unified · Split
| @@ -175,12 +175,11 @@ sub do_nm · 174 unmodified lines | ||
| 175 | 175 | } |
| 176 | 176 | if (! -e "$source.c" && ! -e "$source.S") { |
| 177 | 177 | # No obvious source, exclude the object if it is conglomerate |
| 178 | − if (! open(OBJDUMPDATA, "$objdump $basename|")) { | |
| 179 | − printf STDERR "$objdump $fullname failed $!\n"; | |
| 180 | − return; | |
| 181 | − } | |
| 178 | + open(my $objdumpdata, "$objdump $basename|") | |
| 179 | + or die "$objdump $fullname failed $!\n"; | |
| 180 | + | |
| 182 | 181 | my $comment; |
| 183 | − while (<OBJDUMPDATA>) { | |
| 182 | + while (<$objdumpdata>) { | |
| 184 | 183 | chomp(); |
| 185 | 184 | if (/^In archive/) { |
| 186 | 185 | # Archives are always conglomerate |
| @@ -190,18 +189,18 @@ sub do_nm · 3 unmodified lines | ||
| 190 | 189 | next if (! /^[ 0-9a-f]{5,} /); |
| 191 | 190 | $comment .= substr($_, 43); |
| 192 | 191 | } |
| 193 | − close(OBJDUMPDATA); | |
| 192 | + close($objdumpdata); | |
| 193 | + | |
| 194 | 194 | if (!defined($comment) || $comment !~ /GCC\:.*GCC\:/m) { |
| 195 | 195 | printf STDERR "No source file found for $fullname\n"; |
| 196 | 196 | } |
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | − if (! open(NMDATA, "$nm $basename|")) { | |
| 200 | − printf STDERR "$nm $fullname failed $!\n"; | |
| 201 | − return; | |
| 202 | − } | |
| 199 | + open (my $nmdata, "$nm $basename|") | |
| 200 | + or die "$nm $fullname failed $!\n"; | |
| 201 | + | |
| 203 | 202 | my @nmdata; |
| 204 | − while (<NMDATA>) { | |
| 203 | + while (<$nmdata>) { | |
| 205 | 204 | chop; |
| 206 | 205 | ($type, $name) = (split(/ +/, $_, 3))[1..2]; |
| 207 | 206 | # Expected types |
| @@ -268,7 +267,8 @@ sub do_nm · 60 unmodified lines | ||
| 268 | 267 | } |
| 269 | 268 | } |
| 270 | 269 | } |
| 271 | − close(NMDATA); | |
| 270 | + close($nmdata); | |
| 271 | + | |
| 272 | 272 | if ($#nmdata < 0) { |
| 273 | 273 | if ( |
| 274 | 274 | $fullname ne "lib/brlock.o" |
| @@ -316,8 +316,7 @@ sub drop_def · 41 unmodified lines | ||
| 316 | 316 | |
| 317 | 317 | sub list_multiply_defined |
| 318 | 318 | { |
| 319 | − my ($name, $module); | |
| 320 | − foreach $name (keys(%def)) { | |
| 319 | + foreach my $name (keys(%def)) { | |
| 321 | 320 | if ($#{$def{$name}} > 0) { |
| 322 | 321 | # Special case for cond_syscall |
| 323 | 322 | if ($#{$def{$name}} == 1 && $name =~ /^sys_/ && |
| @@ -333,8 +332,9 @@ sub list_multiply_defined · 9 unmodified lines | ||
| 333 | 332 | &drop_def("arch/x86/kernel/vsyscall-sysenter_32.o", $name); |
| 334 | 333 | next; |
| 335 | 334 | } |
| 335 | + | |
| 336 | 336 | printf "$name is multiply defined in :-\n"; |
| 337 | − foreach $module (@{$def{$name}}) { | |
| 337 | + foreach my $module (@{$def{$name}}) { | |
| 338 | 338 | printf "\t$module\n"; |
| 339 | 339 | } |
| 340 | 340 | } |
| @@ -343,12 +343,13 @@ sub list_multiply_defined · 2 unmodified lines | ||
| 343 | 343 | |
| 344 | 344 | sub resolve_external_references |
| 345 | 345 | { |
| 346 | − my ($object, $type, $name, $i, $j, $kstrtab, $ksymtab, $export); | |
| 346 | + my ($kstrtab, $ksymtab, $export); | |
| 347 | + | |
| 347 | 348 | printf "\n"; |
| 348 | − foreach $object (keys(%nmdata)) { | |
| 349 | + foreach my $object (keys(%nmdata)) { | |
| 349 | 350 | my $nmdata = $nmdata{$object}; |
| 350 | − for ($i = 0; $i <= $#{$nmdata}; ++$i) { | |
| 351 | − ($type, $name) = split(' ', $nmdata->[$i], 2); | |
| 351 | + for (my $i = 0; $i <= $#{$nmdata}; ++$i) { | |
| 352 | + my ($type, $name) = split(' ', $nmdata->[$i], 2); | |
| 352 | 353 | if ($type eq "U" || $type eq "w") { |
| 353 | 354 | if (exists($def{$name}) || exists($ksymtab{$name})) { |
| 354 | 355 | # add the owning object to the nmdata |
| @@ -357,7 +358,7 @@ sub resolve_external_references · 2 unmodified lines | ||
| 357 | 358 | $kstrtab = "R __kstrtab_$name"; |
| 358 | 359 | $ksymtab = "R __ksymtab_$name"; |
| 359 | 360 | $export = 0; |
| 360 | − for ($j = 0; $j <= $#{$nmdata}; ++$j) { | |
| 361 | + for (my $j = 0; $j <= $#{$nmdata}; ++$j) { | |
| 361 | 362 | if ($nmdata->[$j] eq $kstrtab || |
| 362 | 363 | $nmdata->[$j] eq $ksymtab) { |
| 363 | 364 | $export = 1; |
| @@ -424,11 +425,11 @@ sub resolve_external_references · 60 unmodified lines | ||
| 424 | 425 | sub list_extra_externals |
| 425 | 426 | { |
| 426 | 427 | my %noref = (); |
| 427 | − my ($name, @module, $module, $export); | |
| 428 | − foreach $name (keys(%def)) { | |
| 428 | + | |
| 429 | + foreach my $name (keys(%def)) { | |
| 429 | 430 | if (! exists($ref{$name})) { |
| 430 | − @module = @{$def{$name}}; | |
| 431 | − foreach $module (@module) { | |
| 431 | + my @module = @{$def{$name}}; | |
| 432 | + foreach my $module (@module) { | |
| 432 | 433 | if (! exists($noref{$module})) { |
| 433 | 434 | $noref{$module} = []; |
| 434 | 435 | } |
| @@ -438,16 +439,16 @@ sub list_extra_externals · 3 unmodified lines | ||
| 438 | 439 | } |
| 439 | 440 | if (%noref) { |
| 440 | 441 | printf "\nExternally defined symbols with no external references\n"; |
| 441 | − foreach $module (sort(keys(%noref))) { | |
| 442 | + foreach my $module (sort(keys(%noref))) { | |
| 442 | 443 | printf " $module\n"; |
| 443 | 444 | foreach (sort(@{$noref{$module}})) { |
| 444 | − if (exists($export{$_})) { | |
| 445 | − $export = " (export only)"; | |
| 446 | − } | |
| 447 | − else { | |
| 448 | − $export = ""; | |
| 449 | − } | |
| 450 | − printf " $_$export\n"; | |
| 445 | + my $export; | |
| 446 | + if (exists($export{$_})) { | |
| 447 | + $export = " (export only)"; | |
| 448 | + } else { | |
| 449 | + $export = ""; | |
| 450 | + } | |
| 451 | + printf " $_$export\n"; | |
| 451 | 452 | } |
| 452 | 453 | } |
| 453 | 454 | } |