[PATCH 1/5] scripts/kconfig.pl: fixup subroutine style

Elliott Mitchell ehem+openwrt at m5p.com
Wed Nov 29 21:34:11 PST 2023


Match usual Perl style to make the operation of the script easier
to understand for future developers.

Signed-off-by: Elliott Mitchell <ehem+openwrt at m5p.com>
---
 scripts/kconfig.pl | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/scripts/kconfig.pl b/scripts/kconfig.pl
index 392f1d5841..f7b3814cdd 100755
--- a/scripts/kconfig.pl
+++ b/scripts/kconfig.pl
@@ -13,10 +13,7 @@ my @arg;
 my $PREFIX = "CONFIG_";
 
 sub set_config($$$$) {
-	my $config = shift;
-	my $idx = shift;
-	my $newval = shift;
-	my $mod_plus = shift;
+	my ($config, $idx, $newval, $mod_plus) = @_;
 
 	if (!defined($config->{$idx}) or !$mod_plus or
 	    $config->{$idx} eq '#undef' or $newval eq 'y') {
@@ -25,8 +22,7 @@ sub set_config($$$$) {
 }
 
 sub load_config($$) {
-	my $file = shift;
-	my $mod_plus = shift;
+	my ($file, $mod_plus) = @_;
 	my %config;
 
 	open FILE, "$file" or die "can't open file '$file'";
@@ -48,8 +44,7 @@ sub load_config($$) {
 
 
 sub config_and($$) {
-	my $cfg1 = shift;
-	my $cfg2 = shift;
+	my ($cfg1, $cfg2) = @_;
 	my %config;
 
 	foreach my $config (keys %$cfg1) {
@@ -64,9 +59,7 @@ sub config_and($$) {
 
 
 sub config_add($$$) {
-	my $cfg1 = shift;
-	my $cfg2 = shift;
-	my $mod_plus = shift;
+	my ($cfg1, $cfg2, $mod_plus) = @_;
 	my %config;
 	
 	for ($cfg1, $cfg2) {
@@ -84,9 +77,7 @@ sub config_add($$$) {
 }
 
 sub config_diff($$$) {
-	my $cfg1 = shift;
-	my $cfg2 = shift;
-	my $new_only = shift;
+	my ($cfg1, $cfg2, $new_only) = @_;
 	my %config;
 	
 	foreach my $config (keys %$cfg2) {
@@ -99,8 +90,7 @@ sub config_diff($$$) {
 }
 
 sub config_sub($$) {
-	my $cfg1 = shift;
-	my $cfg2 = shift;
+	my ($cfg1, $cfg2) = @_;
 	my %config = %{$cfg1};
 	my @keys = map {
 		my $expr = $_;
@@ -117,8 +107,7 @@ sub config_sub($$) {
 }
 
 sub print_cfgline($$) {
-	my $name = shift;
-	my $val = shift;
+	my ($name, $val) = @_;
 	if ($val eq '#undef' or $val eq 'n') {
 		print "# $PREFIX$name is not set\n";
 	} else {
@@ -128,7 +117,7 @@ sub print_cfgline($$) {
 
 
 sub dump_config($) {
-	my $cfg = shift;
+	my ($cfg) = @_;
 	die "argument error in dump_config" unless ($cfg);
 	my %config = %$cfg;
 	foreach my $config (sort keys %config) {
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+openwrt at m5p.com     PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445






More information about the openwrt-devel mailing list