Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Hamdy Abou El Anein <info@daylightlinux.ch>
To: nathan@kernel.org, nsc@kernel.org
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	sam@ravnborg.org, tim.bird@am.sony.com
Subject: [PATCH] kconfig: diffconfig: preserve a final line without a newline
Date: Tue,  1 Dec 2026 23:01:03 +0100	[thread overview]
Message-ID: <20261201220103.12350-1-info@daylightlinux.ch> (raw)

readconfig() unconditionally removes the last character of each line.
If a configuration fragment has no terminating newline, diffconfig
truncates its last value or fails to recognize an unset option.

For example, comparing CONFIG_FOO=y followed by a newline with the
same line without a newline reports a change from y to an empty value.

Strip only the newline instead of removing the final character.

Tested with identical and changed values, unset options without a final
newline, and regular newline-terminated files.

AI assistance: ChatGPT identified the bug by inspecting the script and
prepared the fix, commit message and local regression tests.

Fixes: a717417e7f96 ("kconfig: add diffconfig utility")
Signed-off-by: Hamdy Abou El Anein <info@daylightlinux.ch>
---
 scripts/diffconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/diffconfig b/scripts/diffconfig
index 43f0f3d273ae..9e84288e0d1f 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -40,7 +40,7 @@ Example usage:
 def readconfig(config_file):
     d = {}
     for line in config_file:
-        line = line[:-1]
+        line = line.rstrip("\n")
         if line[:7] == "CONFIG_":
             name, val = line[7:].split("=", 1)
             d[name] = val
-- 
2.56.1


                 reply	other threads:[~2026-12-01 22:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201220103.12350-1-info@daylightlinux.ch \
    --to=info@daylightlinux.ch \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=tim.bird@am.sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox