diff options
| author | Julian Braha <julianbraha@gmail.com> | 2026-09-15 22:15:08 +0100 |
|---|---|---|
| committer | Nathan Chancellor <nathan@kernel.org> | 2026-09-17 16:31:01 -0700 |
| commit | 9b8719973ee2c5ec23aab9b958e5c6fbdf352f90 (patch) | |
| tree | 82d1111180bf1c72b62b1e5fb8501b0d5fc3c29a /scripts/kconfig/tests/warn_changed_input | |
| parent | 54f11924e4854177b357af499ebc447dc8c3c590 (diff) | |
kconfig: use unsigned integers for hex range checks
While 'hex' values should use the bounds of 64-bit unsigned integers, the
range values are treated as signed (checks use strtoll).
For example:
config HEX_RANGE
hex
range 0 0xfffffffffffffffe
default 0xffffffffffffffff
the default value should adjust down to the upper bound of
0xfffffffffffffffe, but since the check incorrectly parses both as
LLONG_MAX, the value stays at the out-of-range default of
0xffffffffffffffff.
To fix this, let's use a union of signed and unsigned integers to
represent both 'int' and 'hex' range values, then use both strtoll and
strtoull where appropriate.
Assisted-by: LLM
Signed-off-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Nicolas Schier <n.schier@fritz.com>
Link: https://patch.msgid.link/20260915211508.291790-6-julianbraha@gmail.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Diffstat (limited to 'scripts/kconfig/tests/warn_changed_input')
| -rw-r--r-- | scripts/kconfig/tests/warn_changed_input/Kconfig | 5 | ||||
| -rw-r--r-- | scripts/kconfig/tests/warn_changed_input/expected_config | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/scripts/kconfig/tests/warn_changed_input/Kconfig b/scripts/kconfig/tests/warn_changed_input/Kconfig index 69845e2f3fb3..df4183a08420 100644 --- a/scripts/kconfig/tests/warn_changed_input/Kconfig +++ b/scripts/kconfig/tests/warn_changed_input/Kconfig @@ -26,6 +26,11 @@ config NUM Kconfig resolves it to the constrained in-range value. The warning should report that adjustment. +config HEX_RANGE + hex + range 0 0xfffffffffffffffe + default 0xffffffffffffffff + config DUP bool "DUP" depends on DEP diff --git a/scripts/kconfig/tests/warn_changed_input/expected_config b/scripts/kconfig/tests/warn_changed_input/expected_config index fe8bbec66c53..6a8d98a69b7e 100644 --- a/scripts/kconfig/tests/warn_changed_input/expected_config +++ b/scripts/kconfig/tests/warn_changed_input/expected_config @@ -4,3 +4,4 @@ # # CONFIG_DEP is not set CONFIG_NUM=20 +CONFIG_HEX_RANGE=0xfffffffffffffffe |
