History

headers_install: use local file handles

Better practice to use 3 arg open and local file handles.

Stephen Hemminger committed 16 years ago

Commit bae4cec1 parent dbbe33e1 file · +10 −9Browse files

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

Unified · Split

scripts/headers_install.pl+10−9
@@ -23,13 +23,13 @@ my ($readdir, $installdir, $arch, @files) = @ARGV; · 22 unmodified lines
2323 my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__";
2424
2525 foreach my $file (@files) {
26− local *INFILE;
27− local *OUTFILE;
2826 my $tmpfile = "$installdir/$file.tmp";
29− open(INFILE, "<$readdir/$file")
30− or die "$readdir/$file: $!\n";
31− open(OUTFILE, ">$tmpfile") or die "$tmpfile: $!\n";
32− while (my $line = <INFILE>) {
27+
28+ open(my $in, '<', "$readdir/$file")
29+ or die "$readdir/$file: $!\n";
30+ open(my $out, '>', $tmpfile)
31+ or die "$tmpfile: $!\n";
32+ while (my $line = <$in>) {
3333 $line =~ s/([\s(])__user\s/$1/g;
3434 $line =~ s/([\s(])__force\s/$1/g;
3535 $line =~ s/([\s(])__iomem\s/$1/g;
@@ -39,10 +39,11 @@ foreach my $file (@files) { · 3 unmodified lines
3939 $line =~ s/(^|\s)(inline)\b/$1__$2__/g;
4040 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
4141 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g;
42− printf OUTFILE "%s", $line;
42+ printf {$out} "%s", $line;
4343 }
44− close OUTFILE;
45− close INFILE;
44+ close $out;
45+ close $in;
46+
4647 system $unifdef . " $tmpfile > $installdir/$file";
4748 unlink $tmpfile;
4849 }