kconfig: warn about malformed KCONFIG_PROBABILITY valuesrandconfig checks the numeric range of each probability but does notvalidate where strtol() stops. For example, KCONFIG_PROBABILITY=50% isa
kconfig: warn about malformed KCONFIG_PROBABILITY valuesrandconfig checks the numeric range of each probability but does notvalidate where strtol() stops. For example, KCONFIG_PROBABILITY=50% isaccepted as 50:0:0: the '%' is parsed repeatedly as zero. For thedocumented value 50, tristate y/m/n probabilities are 25%/25%/50%.With 50%, both y/m probabilities silently become zero, reducing thecoverage of random configuration builds. Empty fields and extra fieldsare also accepted.Warn when the value does not follow the documented decimal format. Formalformed inputs whose parsed probabilities are in range, preserve theexisting interpretation unless KCONFIG_WERROR is set. In that case, exitwith an error before writing the configuration. Leading whitespace andsigns are accepted by strtol(), but also trigger the warning because theyare outside the documented format.Keep the strtol() result as long until the range check. This rejectsout-of-range values that narrowing to int previously made valid, such as4294967296 becoming zero on a 64-bit host, regardless of KCONFIG_WERROR.Add regression tests for one warning per malformed input, preservedconfigurations, KCONFIG_WERROR, out-of-range values, the supportedprobability formats, and the documented empty-value default.Fixes: e43956e60769 ("kconfig: implement KCONFIG_PROBABILITY for randconfig")Assisted-by: LLMSigned-off-by: Dmitrii Tulnov <tulnov.dl@gmail.com>Tested-by: Julian Braha <julianbraha@gmail.com>Reviewed-by: Julian Braha <julianbraha@gmail.com>Link: https://patch.msgid.link/20260918213430.3-1-tulnov.dl@gmail.comSigned-off-by: Nathan Chancellor <nathan@kernel.org>
show more ...