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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240913171205.22126-6-david.hunter.linux@gmail.com>
Date: Fri, 13 Sep 2024 13:12:00 -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
Subject: [PATCH 5/7] linux-kbuild: 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>
---
 scripts/kconfig/streamline_config.pl | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 26e544744579..593df824ead7 100755
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -162,6 +162,10 @@ sub read_kconfig {
 
     my $source = "$ksource/$kconfig";
     my $last_source = "";
+    my $choice_activated = 0;
+    my $distribute = 0;
+    my $dist_string;
+
 
     # Check for any environment variables used
     while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) {
@@ -214,6 +218,19 @@ sub read_kconfig {
 		$state = "DEP";
 	    }
 
+           if($choice_activated) {
+               $distribute = 0;
+               my $config_lines = "$_\n" . "$dist_string";
+               my $tmpconfig = ".choice.kconfig";
+               open (my $FH, '>', $tmpconfig);
+               print $FH $config_lines;
+               close($FH);
+
+               read_kconfig($tmpconfig);
+               unlink($tmpconfig) or die "Can't delete $tmpconfig: $!\n";
+           }
+
+
 	# collect the depends for the config
 	} elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
 	    $state = "DEP";
@@ -258,8 +275,27 @@ sub read_kconfig {
 	    $iflevel-- if ($iflevel);
 
 	# stop on "help" and keywords that end a menu entry
-	} elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) {
-	    $state = "NONE";
+	} 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/) {
+	    $state = "CHOICE";
+	    $choice_activated = 1;
+	    $distribute = 1;
+	} elsif(/^\s*endchoice/) {
+	    $choice_activated = 0;
+	    $dist_string = "";
+	}
+
+	if($choice_activated && $distribute) {
+	    # do not put 'choice' inside of string to distribute
+	    if($state eq "CHOICE") {
+		    $state = "NONE";
+	    } else {
+		$dist_string .= "$_\n";
+	    }
 	}
     }
     close($kinfile);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ