Better practice to use 3 arg open and local file handles.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -23,13 +23,13 @@ my ($readdir, $installdir, $arch, @files) = @ARGV; · 22 unmodified lines | ||
| 23 | 23 | my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"; |
| 24 | 24 | |
| 25 | 25 | foreach my $file (@files) { |
| 26 | − local *INFILE; | |
| 27 | − local *OUTFILE; | |
| 28 | 26 | 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>) { | |
| 33 | 33 | $line =~ s/([\s(])__user\s/$1/g; |
| 34 | 34 | $line =~ s/([\s(])__force\s/$1/g; |
| 35 | 35 | $line =~ s/([\s(])__iomem\s/$1/g; |
| @@ -39,10 +39,11 @@ foreach my $file (@files) { · 3 unmodified lines | ||
| 39 | 39 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; |
| 40 | 40 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; |
| 41 | 41 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; |
| 42 | − printf OUTFILE "%s", $line; | |
| 42 | + printf {$out} "%s", $line; | |
| 43 | 43 | } |
| 44 | − close OUTFILE; | |
| 45 | − close INFILE; | |
| 44 | + close $out; | |
| 45 | + close $in; | |
| 46 | + | |
| 46 | 47 | system $unifdef . " $tmpfile > $installdir/$file"; |
| 47 | 48 | unlink $tmpfile; |
| 48 | 49 | } |