From: Nicolas Schier <nsc@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Nathan Chancellor <nathan@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
linux-kbuild@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Thomas Meyer <thomas@m3y3r.de>, Miguel Ojeda <ojeda@kernel.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kconfig: add optional warnings for changed input values
Date: Wed, 20 May 2026 16:31:30 +0200 [thread overview]
Message-ID: <ag3FwqUottk-pIkL@derry.ads.avm.de> (raw)
In-Reply-To: <20260406233001.1-kconfig-warn-changed-input-pengpeng@iscas.ac.cn>
[-- Attachment #1: Type: text/plain, Size: 3714 bytes --]
On Mon, Apr 06, 2026 at 11:06:19PM +0800, Pengpeng Hou wrote:
> When reading .config input, Kconfig stores user-provided values first and
> then resolves the final value after applying dependencies, ranges, and
> other constraints.
>
> If the final value differs from the user's input, Kconfig already tracks
> that state internally, but it does not provide any focused diagnostic to
> show which explicit inputs were adjusted. This is particularly confusing
> for requested values that get forced down by unmet dependencies or clamped
> by ranges.
>
> Add an opt-in diagnostic controlled by KCONFIG_WARN_CHANGED_INPUT.
> Emit the warnings from conf_write() and conf_write_defconfig() after
> value resolution and through the existing message callback path so the
> default behavior stays unchanged and interactive frontends remain usable.
>
> Document the new environment variable and add tests for both olddefconfig
> and savedefconfig.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
Thanks a lot for this patch! I know quite some people waiting for that
feature! Just a minor nit-pick, and two minor issues found from
Sashiko; see below.
[...]
> @@ -759,7 +825,10 @@ int conf_write_defconfig(const char *filename)
> {
> struct symbol *sym;
> struct menu *menu;
> + struct gstr gs = str_new();
> FILE *out;
> + bool warn_changed_input = conf_warn_changed_input_enabled();
> + bool found = false;
nit-picking: I'd favor a more descriptive variable name (e.g.
'changed_input_found'), as I am expecting my future me to have to dig
into conf_warn_changed_input_enabled() what that 'found' might really
mean.
[...]
> @@ -798,6 +870,13 @@ int conf_write_defconfig(const char *filename)
> print_symbol_for_dotconfig(out, sym);
> }
> fclose(out);
> +
> + conf_clear_written_flags();
> +
> + if (found)
> + conf_message("%s", str_get(&gs));
Sashiko complains [1] that conf_message() may truncate the output to
4096 bytes, which can easily be provoked, e.g. by switching ARCH.
[...]
> @@ -809,7 +888,10 @@ int conf_write(const char *name)
> const char *str;
> char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
> char *env;
> + struct gstr gs = str_new();
> bool need_newline = false;
> + bool warn_changed_input = conf_warn_changed_input_enabled();
> + bool found = false;
>
> if (!name)
> name = conf_get_configname();
> @@ -859,6 +941,8 @@ int conf_write(const char *name)
> } else if (!sym_is_choice(sym) &&
> !(sym->flags & SYMBOL_WRITTEN)) {
> sym_calc_value(sym);
> + if (warn_changed_input)
> + conf_append_changed_input_warning(&gs, sym, &found);
> if (!(sym->flags & SYMBOL_WRITE))
> goto next;
Sashiko asks about possibly duplicated warnings:
| Will duplicate warning messages be emitted for symbols that have multiple menu
| entries and are forced off (so SYMBOL_WRITE is not set)?
| Since this skips the rest of the loop via goto next;, the symbol is never
| marked with SYMBOL_WRITTEN (which happens later in the block). When the menu
| traversal encounters the same symbol at its next menu node, it will process it
| again and redundantly append the exact same warning.
But from what I can find in in-tree Kconfigs, we do not have Kconfig symbols
that are accessible from multiple menu entries. But it would be good if
someone else could check that once again.
So, thanks again for this small but great feature!
Tested-by: Nicolas Schier <nsc@kernel.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Thanks!
[1]: http://sashiko.dev/#/patchset/20260406233001.1-kconfig-warn-changed-input-pengpeng%40iscas.ac.cn
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2026-05-20 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 15:06 [PATCH] kconfig: add optional warnings for changed input values Pengpeng Hou
2026-05-20 14:31 ` Nicolas Schier [this message]
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=ag3FwqUottk-pIkL@derry.ads.avm.de \
--to=nsc@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=ojeda@kernel.org \
--cc=pengpeng@iscas.ac.cn \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=thomas@m3y3r.de \
/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