Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] scripts: kconfig: merge_config.sh: treat =n and "is not set" as equal
@ 2026-11-30 14:45 Gibson Bell
  2026-11-30 17:50 ` Julian Braha
  0 siblings, 1 reply; 2+ messages in thread
From: Gibson Bell @ 2026-11-30 14:45 UTC (permalink / raw)
  To: nathan, nsc
  Cc: Gibson Bell, linux-kbuild, Julian Braha, Mikko Rapeli,
	Anders Roxell

If the base config has CONFIG_FOO=n and a fragment has
"# CONFIG_FOO is not set", both lines end up in the merged config and
Kconfig complains about reassigning the symbol, which is fatal with
KCONFIG_WERROR=1. Merging them the other way round trips strict mode
instead.

Both forms mean the same thing to Kconfig, so treat them as redundant
whichever one comes first. Before the switch to awk, strict mode
rejected both orders; now it accepts both.

Fixes: 5fa9b82cbcfc ("scripts: kconfig: merge_config.sh: refactor from shell/sed/grep to awk")
Signed-off-by: Gibson Bell <gibson@gibsonbell.com>
---
To reproduce from the top of the tree:

  printf '# CONFIG_PM is not set\n' > base.config
  printf 'CONFIG_PM=n\n' > fragment.config
  ./scripts/kconfig/merge_config.sh -m -s base.config fragment.config

This fails in strict mode. Swap the two files and it succeeds, but
.config has both lines. With the patch, both orders succeed and .config
has a single line.

Tested -m with and without -s, in both orders, under bash and dash.

Thanks,
Gibson

 scripts/kconfig/merge_config.sh | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index ec242e0..bc8e607 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -228,18 +228,15 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
 			next
 		}
 
-		# Values equal - redundant
-		if (prev_val == new_val) {
+		# Values equal - redundant (including both forms of n)
+		notset_val = "# " cfg " is not set"
+		if (prev_val == new_val ||
+		    (prev_val == cfg "=n" && new_val == notset_val) ||
+		    (prev_val == notset_val && new_val == cfg "=n")) {
 			warn_redundant(cfg)
 			next
 		}
 
-		# "=n" is the same as "is not set"
-		if (prev_val ~ /=n$/ && new_val ~ / is not set$/) {
-			print $0 >> outfile
-			next
-		}
-
 		# Values differ - redefined
 		warn_redefined(cfg, prev_val, new_val)
 		if (strict == "true") {

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.54.0 (Apple Git-157)


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

end of thread, other threads:[~2026-11-30 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 14:45 [PATCH] scripts: kconfig: merge_config.sh: treat =n and "is not set" as equal Gibson Bell
2026-11-30 17:50 ` Julian Braha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox