All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] minor changes to kconfig/streamline_config.pl
@ 2012-08-09 13:23 Bill Pemberton
  2012-08-09 13:23 ` [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl Bill Pemberton
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Bill Pemberton @ 2012-08-09 13:23 UTC (permalink / raw)
  To: linux-kbuild; +Cc: rostedt

All of these are changes to streamline_config.pl

The first one fixes a warning message that perl emits when running the
script.  It also has the the side effect of fixing a bug.

The second two convert the open calls to use the 3 parameter open that
is now preferred in modern perl.

The last one is a simple fix to make perlcritic happy.

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(-)

-- 
1.7.11.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl
  2012-08-09 13:23 [PATCH 0/4] minor changes to kconfig/streamline_config.pl Bill Pemberton
@ 2012-08-09 13:23 ` Bill Pemberton
  2012-08-09 14:07   ` Steven Rostedt
  2012-08-09 13:23 ` [PATCH 2/4] localmodconfig: rework find_config in streamline_config.pl Bill Pemberton
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Bill Pemberton @ 2012-08-09 13:23 UTC (permalink / raw)
  To: linux-kbuild; +Cc: rostedt

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.

This also fixes passing a config file to the script.  For example,
without this is if you run streamline_config.pl . config.old, it will
ignore config.old and try to read .config anyway.  With this change it
will read config.old instead of .config -- which appears to be the
intent of the code.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
 scripts/kconfig/streamline_config.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 2fbbbc1d..e3687f9 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -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'};
 
-- 
1.7.11.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] localmodconfig: rework find_config in streamline_config.pl
  2012-08-09 13:23 [PATCH 0/4] minor changes to kconfig/streamline_config.pl Bill Pemberton
  2012-08-09 13:23 ` [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl Bill Pemberton
@ 2012-08-09 13:23 ` Bill Pemberton
  2012-08-09 13:23 ` [PATCH 3/4] localmodconfig: use 3 parameter open " Bill Pemberton
  2012-08-09 13:23 ` [PATCH 4/4] localmodconfig: use my variable for loop " Bill Pemberton
  3 siblings, 0 replies; 9+ messages in thread
From: Bill Pemberton @ 2012-08-09 13:23 UTC (permalink / raw)
  To: linux-kbuild; +Cc: rostedt

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.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
 scripts/kconfig/streamline_config.pl | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index e3687f9..62d64ce 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -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;
-- 
1.7.11.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] localmodconfig: use 3 parameter open in streamline_config.pl
  2012-08-09 13:23 [PATCH 0/4] minor changes to kconfig/streamline_config.pl Bill Pemberton
  2012-08-09 13:23 ` [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl Bill Pemberton
  2012-08-09 13:23 ` [PATCH 2/4] localmodconfig: rework find_config in streamline_config.pl Bill Pemberton
@ 2012-08-09 13:23 ` Bill Pemberton
  2012-08-09 13:23 ` [PATCH 4/4] localmodconfig: use my variable for loop " Bill Pemberton
  3 siblings, 0 replies; 9+ messages in thread
From: Bill Pemberton @ 2012-08-09 13:23 UTC (permalink / raw)
  To: linux-kbuild; +Cc: rostedt

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

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
 scripts/kconfig/streamline_config.pl | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 62d64ce..22b66ca 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -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
-- 
1.7.11.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] localmodconfig: use my variable for loop in streamline_config.pl
  2012-08-09 13:23 [PATCH 0/4] minor changes to kconfig/streamline_config.pl Bill Pemberton
                   ` (2 preceding siblings ...)
  2012-08-09 13:23 ` [PATCH 3/4] localmodconfig: use 3 parameter open " Bill Pemberton
@ 2012-08-09 13:23 ` Bill Pemberton
  3 siblings, 0 replies; 9+ messages in thread
From: Bill Pemberton @ 2012-08-09 13:23 UTC (permalink / raw)
  To: linux-kbuild; +Cc: rostedt

perlcritic complains about $kconfig being reused in the foreach loop
at the end of read_kconfig.  Change it to a my variable.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
 scripts/kconfig/streamline_config.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 22b66ca..39b6314 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -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);
-- 
1.7.11.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl
  2012-08-09 13:23 ` [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl Bill Pemberton
@ 2012-08-09 14:07   ` Steven Rostedt
  2012-08-09 14:16     ` [PATCH 1/4] localmodconfig: set default value for ksource in Bill Pemberton
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2012-08-09 14:07 UTC (permalink / raw)
  To: Bill Pemberton; +Cc: linux-kbuild

On Thu, 2012-08-09 at 09:23 -0400, Bill Pemberton wrote:
> 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.
> 
> This also fixes passing a config file to the script.  For example,
> without this is if you run streamline_config.pl . config.old, it will
> ignore config.old and try to read .config anyway.  With this change it
> will read config.old instead of .config -- which appears to be the
> intent of the code.

I have nothing against this change, but I'm confused by how it fixes the
above issue about reading config.old.

Without the patch, passing in both '.' and 'config.old' as parameters,
wouldn't that still set $ksource to '.' and $kconfig to config.old?

Perhaps, it failed for you without passing the '.', which would set
$ksource to config.old. Maybe the real change should be to count the
number of parameters to determine what $kconfig and $ksource get set to?

-- Steve

> 
> Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
> ---
>  scripts/kconfig/streamline_config.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
> index 2fbbbc1d..e3687f9 100644
> --- a/scripts/kconfig/streamline_config.pl
> +++ b/scripts/kconfig/streamline_config.pl
> @@ -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'};
>  



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] localmodconfig: set default value for ksource in
  2012-08-09 14:07   ` Steven Rostedt
@ 2012-08-09 14:16     ` Bill Pemberton
  2012-08-09 14:58       ` Steven Rostedt
  0 siblings, 1 reply; 9+ messages in thread
From: Bill Pemberton @ 2012-08-09 14:16 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kbuild

Steven Rostedt writes:
> 
> I have nothing against this change, but I'm confused by how it fixes the
> above issue about reading config.old.
> 
> Without the patch, passing in both '.' and 'config.old' as parameters,
> wouldn't that still set $ksource to '.' and $kconfig to config.old?
> 
> Perhaps, it failed for you without passing the '.', which would set
> $ksource to config.old. Maybe the real change should be to count the
> number of parameters to determine what $kconfig and $ksource get set to?
> 

You're right, I remembered the warning and the bug I encountered, but
forgot that this patch only addresses the warning.

The problem is that if you do  streamline_config.pl . config.old, it
doesn't read config.old at all -- it still reads .config.

-- 
Bill



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] localmodconfig: set default value for ksource in
  2012-08-09 14:16     ` [PATCH 1/4] localmodconfig: set default value for ksource in Bill Pemberton
@ 2012-08-09 14:58       ` Steven Rostedt
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2012-08-09 14:58 UTC (permalink / raw)
  To: Bill Pemberton; +Cc: linux-kbuild

On Thu, 2012-08-09 at 10:16 -0400, Bill Pemberton wrote:

> You're right, I remembered the warning and the bug I encountered, but
> forgot that this patch only addresses the warning.
> 
> The problem is that if you do  streamline_config.pl . config.old, it
> doesn't read config.old at all -- it still reads .config.
> 

OK, I'll take these patches as is, and fix the change log to not talk
about that issue.

You can send another patch that fixes the issue if you like.

I'll queue them up for 3.7.

-- Steve



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/4] localmodconfig: Rework find_config in streamline_config.pl
  2012-10-01 13:30 [PATCH 0/4] [GIT PULL] localmodconfig: clean ups and fixes Steven Rostedt
@ 2012-10-01 13:30 ` Steven Rostedt
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2012-10-01 13:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds, Bill Pemberton

[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]

From: Bill Pemberton <wfp5p@virginia.edu>

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.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 scripts/kconfig/streamline_config.pl |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index e3687f9..62d64ce 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -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;
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-10-01 13:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-09 13:23 [PATCH 0/4] minor changes to kconfig/streamline_config.pl Bill Pemberton
2012-08-09 13:23 ` [PATCH 1/4] localmodconfig: set default value for ksource in streamline_config.pl Bill Pemberton
2012-08-09 14:07   ` Steven Rostedt
2012-08-09 14:16     ` [PATCH 1/4] localmodconfig: set default value for ksource in Bill Pemberton
2012-08-09 14:58       ` Steven Rostedt
2012-08-09 13:23 ` [PATCH 2/4] localmodconfig: rework find_config in streamline_config.pl Bill Pemberton
2012-08-09 13:23 ` [PATCH 3/4] localmodconfig: use 3 parameter open " Bill Pemberton
2012-08-09 13:23 ` [PATCH 4/4] localmodconfig: use my variable for loop " Bill Pemberton
2012-10-01 13:30 [PATCH 0/4] [GIT PULL] localmodconfig: clean ups and fixes Steven Rostedt
2012-10-01 13:30 ` [PATCH 2/4] localmodconfig: Rework find_config in streamline_config.pl Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.