localmodconfig: Use 3 parameter open in streamline_config.pl

Convert remaining open calls to use the perl's preferred 3 parameter
open.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Bill Pemberton 2012-08-09 09:23:22 -04:00 committed by Steven Rostedt
parent 3f0c541316
commit e0d28694d3
1 changed files with 14 additions and 16 deletions

View File

@ -171,8 +171,8 @@ sub read_kconfig {
$source =~ s/\$$env/$ENV{$env}/; $source =~ s/\$$env/$ENV{$env}/;
} }
open(KIN, "$source") || die "Can't open $kconfig"; open(my $kinfile, '<', $source) || die "Can't open $kconfig";
while (<KIN>) { while (<$kinfile>) {
chomp; chomp;
# Make sure that lines ending with \ continue # Make sure that lines ending with \ continue
@ -249,7 +249,7 @@ sub read_kconfig {
$state = "NONE"; $state = "NONE";
} }
} }
close(KIN); close($kinfile);
# read in any configs that were found. # read in any configs that were found.
foreach $kconfig (@kconfigs) { foreach $kconfig (@kconfigs) {
@ -293,8 +293,8 @@ foreach my $makefile (@makefiles) {
my $line = ""; my $line = "";
my %make_vars; my %make_vars;
open(MIN,$makefile) || die "Can't open $makefile"; open(my $infile, '<', $makefile) || die "Can't open $makefile";
while (<MIN>) { while (<$infile>) {
# if this line ends with a backslash, continue # if this line ends with a backslash, continue
chomp; chomp;
if (/^(.*)\\$/) { if (/^(.*)\\$/) {
@ -341,10 +341,11 @@ foreach my $makefile (@makefiles) {
} }
} }
} }
close(MIN); close($infile);
} }
my %modules; my %modules;
my $linfile;
if (defined($lsmod_file)) { if (defined($lsmod_file)) {
if ( ! -f $lsmod_file) { if ( ! -f $lsmod_file) {
@ -354,13 +355,10 @@ if (defined($lsmod_file)) {
die "$lsmod_file not found"; die "$lsmod_file not found";
} }
} }
if ( -x $lsmod_file) {
# the file is executable, run it my $otype = ( -x $lsmod_file) ? '-|' : '<';
open(LIN, "$lsmod_file|"); open($linfile, $otype, $lsmod_file);
} else {
# Just read the contents
open(LIN, "$lsmod_file");
}
} else { } else {
# see what modules are loaded on this system # see what modules are loaded on this system
@ -377,16 +375,16 @@ if (defined($lsmod_file)) {
$lsmod = "lsmod"; $lsmod = "lsmod";
} }
open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod"; open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod";
} }
while (<LIN>) { while (<$linfile>) {
next if (/^Module/); # Skip the first line. next if (/^Module/); # Skip the first line.
if (/^(\S+)/) { if (/^(\S+)/) {
$modules{$1} = 1; $modules{$1} = 1;
} }
} }
close (LIN); close ($linfile);
# add to the configs hash all configs that are needed to enable # add to the configs hash all configs that are needed to enable
# a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o