* [PATCH] kconfig: diffconfig: preserve a final line without a newline
@ 2026-12-01 22:01 Hamdy Abou El Anein
2026-12-01 23:57 ` Julian Braha
0 siblings, 1 reply; 2+ messages in thread
From: Hamdy Abou El Anein @ 2026-12-01 22:01 UTC (permalink / raw)
To: nathan, nsc; +Cc: linux-kbuild, linux-kernel, sam, tim.bird
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] kconfig: diffconfig: preserve a final line without a newline
2026-12-01 22:01 [PATCH] kconfig: diffconfig: preserve a final line without a newline Hamdy Abou El Anein
@ 2026-12-01 23:57 ` Julian Braha
0 siblings, 0 replies; 2+ messages in thread
From: Julian Braha @ 2026-12-01 23:57 UTC (permalink / raw)
To: Hamdy Abou El Anein, nathan, nsc
Cc: linux-kbuild, linux-kernel, sam, tim.bird
[-- Attachment #1.1: Type: text/plain, Size: 1731 bytes --]
On 12/1/26 22:01, Hamdy Abou El Anein wrote:
> 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")
It would have been better to just do:
line = line.rstrip()
to catch any trailing whitespace too, not only newline characters.
> if line[:7] == "CONFIG_":
> name, val = line[7:].split("=", 1)
> d[name] = val
> -- 2.56.1
>
But, this is an improvement over what we have, so:
Tested-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Julian Braha <julianbraha@gmail.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 23:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 22:01 [PATCH] kconfig: diffconfig: preserve a final line without a newline Hamdy Abou El Anein
2026-12-01 23:57 ` Julian Braha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®