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

From: Geert Uytterhoeven

Date: Tue Sep 01 2026 - 06:47:21 EST


On Mon, 31 Aug 2026 at 14:36, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> 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>

FTR, this will impact all defconfigs that restrict SERIAL_8250_NR_UARTS
to a value lower than 4:

config SERIAL_8250_NR_UARTS
int "Maximum number of 8250/16550 serial ports"
depends on SERIAL_8250
default "4"

config SERIAL_8250_RUNTIME_UARTS
int "Number of 8250/16550 serial ports to register at runtime"
depends on SERIAL_8250
range 0 SERIAL_8250_NR_UARTS
default "4"

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