Commit bae4cecc09db9d472d71cb262de3c976147ad628

Authored by Stephen Hemminger
Committed by Michal Marek
1 parent dbbe33e99f

headers_install: use local file handles

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

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>

Showing 1 changed file with 10 additions and 9 deletions Side-by-side Diff

scripts/headers_install.pl
... ... @@ -23,13 +23,13 @@
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;
36 36  
... ... @@ -39,10 +39,11 @@
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 }