lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241014141345.5680-6-david.hunter.linux@gmail.com>
Date: Mon, 14 Oct 2024 10:13:35 -0400
From: David Hunter <david.hunter.linux@...il.com>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: David Hunter <david.hunter.linux@...il.com>,
	linux-kbuild@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	shuah@...nel.org,
	javier.carrasco.cruz@...il.com,
	Steven Rostedt <rostedt@...dmis.org>
Subject: [PATCH v2 5/7] streamline_config.pl: fix: implement choice for kconfigs

Properly implement the config entries that are within the choice keyword
for kconfig. Currently, the script only stops the previous config entry
when a choice keyword is encountered.

When the keyword "choice" is encountered, do the following:
        - distribute the lines immediately following the "choice"
          keyword to each config entry inside the "choice" section.
        - process the config entries with the distributed lines.

Signed-off-by: David Hunter <david.hunter.linux@...il.com>
---
V1 https://lore.kernel.org/all/20240913171205.22126-6-david.hunter.linux@gmail.com/

V2 
	- changed the subject prefix
	- changed the method for storing and distributing the choice
	  block. No longer using temp file. 
---
 scripts/kconfig/streamline_config.pl | 47 ++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index b7ed79c5e070..4149c4b344db 100755
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -149,6 +149,34 @@ my $var;
 my $iflevel = 0;
 my @ifdeps;
 
+# distributes choice entries to different config options
+sub set_hash_value {
+    my %htable = %{$_[0]};
+    my $tmp_config = $_[1];
+    my $current_config = $_[2];
+    if (defined($htable{$tmp_config})) {
+	${$_[0]}{$current_config} = $htable{$tmp_config};
+    }
+}
+
+# distribute choice config entries
+sub copy_configs {
+    my $tmp_config = "TMP_CONFIG";
+    my $choice_config = $_[0];
+    set_hash_value (\%depends, $tmp_config, $choice_config);
+    set_hash_value (\%selects, $tmp_config, $choice_config);
+    set_hash_value (\%prompts, $tmp_config, $choice_config);
+    set_hash_value (\%defaults, $tmp_config, $choice_config);
+}
+
+sub delete_temp_config {
+    my $tmp_config = "TMP_CONFIG";
+    $depends{$tmp_config} = undef;
+    $selects{$tmp_config} = undef;
+    $prompts{$tmp_config} = undef;
+    $defaults{$tmp_config} = undef;
+}
+
 # prevent recursion
 my %read_kconfigs;
 
@@ -163,6 +191,7 @@ sub read_kconfig {
 
     my $source = "$ksource/$kconfig";
     my $last_source = "";
+    my $choice_activated = 0;
 
     # Check for any environment variables used
     while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) {
@@ -205,9 +234,13 @@ sub read_kconfig {
 	    $config = $2;
 	    $config2kfile{"CONFIG_$config"} = $kconfig;
 
+	    if ($choice_activated) {
+		copy_configs $config;
+	    }
+
 	    # Add depends for 'if' nesting
 	    for (my $i = 0; $i < $iflevel; $i++) {
-		if ($i) {
+		if (defined($depends{$config})) {
 		    $depends{$config} .= " " . $ifdeps[$i];
 		} else {
 		    $depends{$config} = $ifdeps[$i];
@@ -260,8 +293,18 @@ sub read_kconfig {
 	    $iflevel-- if ($iflevel);
 
 	# stop on "help" and keywords that end a menu entry
-	} elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) {
+	} elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|menu)\b/) {
 	    $state = "NONE";
+
+	# for choice, distribute the lines before each config entry to
+	# each config entry
+	} elsif (/^\s*choice\b/) {
+	    $choice_activated = 1;
+	    $config = "TMP_CONFIG";
+	    $state = "NEW";
+	} elsif (/^\s*endchoice/) {
+	    delete_temp_config;
+	    $choice_activated = 0;
 	}
     }
     close($kinfile);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ