localmodconfig: clean ups and fixes
Linus,
Bill Pemberton added some changes to make streamline-config.pl work again as a stand-alone tool (outside of make localmodconfig).
Also, he added a couple of updates to make the code be more "Perl proper".
*Note* I changed the gpg subkey that I use to sign with because the old one is about to expire. You may need to refresh my key to get the new subkeys.
Main key which you should have:
5ED9 A48F C54C 0A22 D1D0 804C EBC2 6CDB 5A56 DE73
Old subkey (expires tomorrow):
C66DAA00
New subkey:
71B30B4C
Please pull the latest localmodconfig-v3.7 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-kconfig.git
localmodconfig-v3.7
Head SHA1: 88050b21c2ca96aff36dc2cb1f29ee72d0a70fe6
Bill Pemberton (4):
localmodconfig: Set default value for ksource in streamline_config.pl
localmodconfig: Rework find_config in streamline_config.pl
localmodconfig: Use 3 parameter open in streamline_config.pl
localmodconfig: Use my variable for loop in streamline_config.pl
----
scripts/kconfig/streamline_config.pl | 48 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 26 deletions(-)
PATCH 1/4 localmodconfig: Set default value for ksource in streamline_config.pl
From: Bill Pemberton <[email protected]>
Running streamline_config.pl as it's shown it in the comment header, you will get a warning about $ksource being uninitialized. This is because $ksource is set to ARGV[0], but the examples don't require any arguments. Fix by setting ksource to . if no ARGV[0] is given.
--- scripts/kconfig/streamline_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/streamline_config.pl +1 -1
@@ -135,7 +135,7 @@ GetOptions("localmodconfig" => \$localmodconfig, "localyesconfig" => \$localyesconfig); # Get the build source and top level Kconfig file (passed in) -my $ksource = $ARGV[0]; +my $ksource = ($ARGV[0] ? $ARGV[0] : '.'); my $kconfig = $ARGV[1]; my $lsmod_file = $ENV{'LSMOD'};
Signature · 1 line
1.7.10.4
PATCH 4/4 localmodconfig: Use my variable for loop in streamline_config.pl
In reply to Steven RostedtFrom: Bill Pemberton <[email protected]>
perlcritic complains about $kconfig being reused in the foreach loop at the end of read_kconfig. Change it to a my variable.
--- scripts/kconfig/streamline_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/streamline_config.pl +1 -1
@@ -252,7 +252,7 @@ sub read_kconfig { close($kinfile); # read in any configs that were found. - foreach $kconfig (@kconfigs) { + foreach my $kconfig (@kconfigs) { if (!defined($read_kconfigs{$kconfig})) { $read_kconfigs{$kconfig} = 1; read_kconfig($kconfig);
Signature · 1 line
1.7.10.4
PATCH 2/4 localmodconfig: Rework find_config in streamline_config.pl
In reply to Steven RostedtFrom: Bill Pemberton <[email protected]>
Change find_config function to read_config. It now finds the config, reads the config into an array, and returns the array. This makes it a little cleaner and changes the open to use perl's 3 option open.
--- scripts/kconfig/streamline_config.pl | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
scripts/kconfig/streamline_config.pl +6 -8
@@ -100,7 +100,7 @@ my @searchconfigs = ( }, ); -sub find_config { +sub read_config { foreach my $conf (@searchconfigs) { my $file = $conf->{"file"};
@@ -115,17 +115,15 @@ sub find_config { print STDERR "using config: '$file'\n"; - open(CIN, "$exec $file |") || die "Failed to run $exec $file"; - return; + open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file"; + my @x = <$infile>; + close $infile; + return @x; } die "No config file found"; } -find_config; - -# Read in the entire config file into config_file -my @config_file = <CIN>; -close CIN; +my @config_file = read_config; # Parse options my $localmodconfig = 0;
Signature · 1 line
1.7.10.4
PATCH 3/4 localmodconfig: Use 3 parameter open in streamline_config.pl
In reply to Steven RostedtFrom: Bill Pemberton <[email protected]>
Convert remaining open calls to use the perl's preferred 3 parameter open.
--- scripts/kconfig/streamline_config.pl | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
scripts/kconfig/streamline_config.pl +14 -16
@@ -171,8 +171,8 @@ sub read_kconfig { $source =~ s/\$$env/$ENV{$env}/; } - open(KIN, "$source") || die "Can't open $kconfig"; - while (<KIN>) { + open(my $kinfile, '<', $source) || die "Can't open $kconfig"; + while (<$kinfile>) { chomp; # Make sure that lines ending with \ continue
@@ -249,7 +249,7 @@ sub read_kconfig { $state = "NONE"; } } - close(KIN); + close($kinfile); # read in any configs that were found. foreach $kconfig (@kconfigs) {
@@ -293,8 +293,8 @@ foreach my $makefile (@makefiles) { my $line = ""; my %make_vars; - open(MIN,$makefile) || die "Can't open $makefile"; - while (<MIN>) { + open(my $infile, '<', $makefile) || die "Can't open $makefile"; + while (<$infile>) { # if this line ends with a backslash, continue chomp; if (/^(.*)\\$/) {
@@ -341,10 +341,11 @@ foreach my $makefile (@makefiles) { } } } - close(MIN); + close($infile); } my %modules; +my $linfile; if (defined($lsmod_file)) { if ( ! -f $lsmod_file) {
@@ -354,13 +355,10 @@ if (defined($lsmod_file)) { die "$lsmod_file not found"; } } - if ( -x $lsmod_file) { - # the file is executable, run it - open(LIN, "$lsmod_file|"); - } else { - # Just read the contents - open(LIN, "$lsmod_file"); - } + + my $otype = ( -x $lsmod_file) ? '-|' : '<'; + open($linfile, $otype, $lsmod_file); + } else { # see what modules are loaded on this system
@@ -377,16 +375,16 @@ if (defined($lsmod_file)) { $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. if (/^(\S+)/) { $modules{$1} = 1; } } -close (LIN); +close ($linfile); # add to the configs hash all configs that are needed to enable # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o
Signature · 1 line
1.7.10.4