Files
Pengpeng Hou 645323a7f4 kconfig: add optional warnings for changed input values
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 input, Kconfig already tracks
that state internally, but it does not provide a 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. Print the diagnostic to stderr directly, not through the
normal message callback, so it remains visible when conf is run with -s,
such as from make -s.

Keep the diagnostic out of the conf_message() formatting buffer so long
warning lists are not truncated, and mark processed symbols as written
before the SYMBOL_WRITE check so duplicate menu nodes cannot emit
duplicate warnings.

Document the new environment variable and add tests for olddefconfig,
savedefconfig, and the silent-conf path.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Tested-by: Julian Braha <julianbraha@gmail.com>
Link: https://patch.msgid.link/20260611060000.23858-1-pengpeng@iscas.ac.cn
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-06-18 11:46:32 -07:00

41 lines
1.1 KiB
Plaintext

# SPDX-License-Identifier: GPL-2.0
config DEP
bool "DEP"
help
Test dependency symbol for Kconfig warning coverage.
This is used by the warn_changed_input selftest.
It intentionally stays unset in the input fragment.
The test checks how dependent user input is adjusted.
config A
bool "A"
depends on DEP
help
Test bool symbol for changed-input diagnostics.
The input fragment requests this symbol as built-in.
The unmet dependency on DEP forces the final value to n.
The warning should report that downgrade.
config NUM
int "NUM"
range 10 20
help
Test integer symbol for changed-input diagnostics.
The input fragment requests a value outside the allowed range.
Kconfig resolves it to the constrained in-range value.
The warning should report that adjustment.
config DUP
bool "DUP"
depends on DEP
help
Test duplicate-definition handling for changed-input diagnostics.
The input fragment requests this symbol as built-in.
The duplicate definition below must not produce a duplicate warning.
This keeps the warning output stable for repeated menu entries.
config DUP
bool
depends on DEP