On Sun, May 05, 2024 at 03:53:53PM +0200, Yoann Congal wrote: > From: Masahiro Yamada <masahi...@kernel.org> > > This is a cherry-pick from the kernel commit: > 6262afa10ef7c (kconfig: default to zero if int/hex symbol lacks default > property, 2023-11-26) > > When a default property is missing in an int or hex symbol, it defaults > to an empty string, which is not a valid symbol value. > > It results in an incorrect .config, and can also lead to an infinite > loop in scripting. > > Use "0" for int and "0x0" for hex as a default value. > > Signed-off-by: Masahiro Yamada <masahi...@kernel.org> > Reviewed-by: Yoann Congal <yoann.con...@smile.fr> > > Signed-off-by: Yoann Congal <yoann.con...@smile.fr> > --- > Added context that was not in the upstream commit: > The infinite loop case happens with a configuration defined like this > (a hex config without a valid default value): > config HEX_TEST > hex "Hex config without default" > > And using: > $ make oldconfig < /dev/null > scripts/kconfig/conf --oldconfig Kconfig > * > * General setup > * > > Error in reading or end of file. > > Error in reading or end of file. > Hex config without default (HEX_TEST) [] (NEW) > > Error in reading or end of file. > Hex config without default (HEX_TEST) [] (NEW) > # This loops forever > > NB: Scripted config manipulation often call make with /dev/null as > stdin (Yocto recipe, CI build, ...) > > This was discovered when working on Yocto bug: > https://bugzilla.yoctoproject.org/show_bug.cgi?id=14136
I'm surprised this was accepted. In the past I've wanted to avoid this kind of change in Kconfig because while the empty string can be easily be checked in the code as "user didn't really configure this, do nothing" a value of zero is a valid option in these cases and so then in the code we need a bool symbol to decide if the hex/int symbol is set or not. Today this is less of an issue than it used to be in U-Boot with everything CONFIG-related migrated to Kconfig and so there's no longer the question of if we missed migrating a file that defined the value but there's still places we have in the code where hex symbol is undefined is not the same thing as hex symbol is 0x0. Is there a specific use case you have for this in U-Boot? It's been a while, but it's also been cases of newly introduced symbols in Kconfig files with incorrect dependencies, where the infinite loop in kconfig happened, CI failed and we caught the problem. -- Tom
signature.asc
Description: PGP signature