Re: [PATCH] kconfig: fix extra output from savedefconfig on out-of-range defaults

From: Geert Uytterhoeven

Date: Mon Aug 31 2026 - 08:38:01 EST


Hi Julian,

Thanks for your patch!

On Mon, 31 Aug 2026 at 00:12, Julian Braha <julianbraha@xxxxxxxxx> wrote:
> The Kconfig interpreter currently allows defaults that are outside of the
> range bounds.
>
> In these cases, the 'sym_validate_range' function will adjust the default
> value to the nearest range bound. For example, see this example:
>
> config A
> int
> range 1 2
> default 16
>
> Here, since the default value of 16 is greater than the bounds, the
> effective default value gets adjusted down to the upper bound, 2.
>
> However, 'savedefconfig' writes non-default values, and without being

s/non-default/non-adjusted/?

> aware of the automatic adjustment to the range bound, it would write: A=2
>
> This limitation is also documented in a comment: "The following fails to
> handle the situation where a default value is further limited by the valid
> range."
>
> To resolve this, let's factor out the default-range adjustment logic from
> the existing 'sym_validate_range' function into its own
> 'sym_get_near_range_bound' function for 'savedefconfig' to use too, so
> that it compares against the effective value.
>
> Adds tests, accordingly.
>
> Fixes: 7cf3d73b4360 ("kconfig: add savedefconfig")
> Assisted-by: Codex:gpt-5.6-sol
> Reported-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> Closes: https://lore.kernel.org/lkml/CAMuHMdVyUAA3L4mUkSjmnuE3cvj-+N8z-Bhxsh1wa-FQWc=fjw@xxxxxxxxxxxxxx/
> Signed-off-by: Julian Braha <julianbraha@xxxxxxxxx>

Thanks, this fixes the issue, and would let us revert commit
ab74edaeb1ae7c71 ("erofs: Fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS
default logic") in v7.3-rc1.

Tested-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds