kconfig: tell the kconfig symbol of the restart reason

Message ID 20230704055246.22893-1-rdunlap@infradead.org
State New
Headers
Series kconfig: tell the kconfig symbol of the restart reason |

Commit Message

Randy Dunlap July 4, 2023, 5:52 a.m. UTC
  When running 'make oldconfig' or 'make olddefconfig' without waiting
for prompts, it can be useful to know the restart reason so that it
can be fixed manually.

This is usually when the prompt value is a number or a string,
i.e., something other than y/m/n.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org
---
Can the test for sym->name be omitted?

 scripts/kconfig/conf.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Comments

Masahiro Yamada July 12, 2023, 3:35 p.m. UTC | #1
On Tue, Jul 4, 2023 at 2:52 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> When running 'make oldconfig' or 'make olddefconfig' without waiting

olddefconfig is not interactive in the first place.

'make config', 'make oldconfig', 'make syncconfig' are affected.


> for prompts, it can be useful to know the restart reason so that it
> can be fixed manually.
>
> This is usually when the prompt value is a number or a string,
> i.e., something other than y/m/n.



I do not understand what you mean.

Please give me some examples to see why this is useful.


BTW, "due to symbol ..." is not the reason for the restart.
It shows the first CONFIG option shown after the restart.



>
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: linux-kbuild@vger.kernel.org
> ---
> Can the test for sym->name be omitted?

Not all symbols have a name.
For example, 'choice' may not have a name.

[test code]

choice
       prompt "A or B"
       depends on FOO

config A
       bool "A"

config B
       bool "B"

endchoice

config FOO
       bool "foo"



If you omit, sym->name test,
"due to symbol: (null)" will be displayed.
Not a crash, but users will be misguided.




foo (FOO) [N/y/?] (NEW) y
*
* Restart config...
* due to symbol: (null)
*
*
* Linux/x86 6.5.0-rc1 Kernel Configuration
*
A or B
> 1. A (A) (NEW)
  2. B (B) (NEW)












>  scripts/kconfig/conf.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff -- a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
> --- a/scripts/kconfig/conf.c
> +++ b/scripts/kconfig/conf.c
> @@ -652,8 +652,12 @@ static void check_conf(struct menu *menu
>                         printf("-----\n");
>                         break;
>                 default:
> -                       if (!conf_cnt++)
> -                               printf("*\n* Restart config...\n*\n");
> +                       if (!conf_cnt++) {
> +                               printf("*\n* Restart config...\n");
> +                               if (sym->name)
> +                                       printf("* due to symbol: %s\n", sym->name);
> +                               printf("*\n");
> +                       }
>                         rootEntry = menu_get_parent_menu(menu);
>                         conf(rootEntry);
>                         break;
  

Patch

diff -- a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -652,8 +652,12 @@  static void check_conf(struct menu *menu
 			printf("-----\n");
 			break;
 		default:
-			if (!conf_cnt++)
-				printf("*\n* Restart config...\n*\n");
+			if (!conf_cnt++) {
+				printf("*\n* Restart config...\n");
+				if (sym->name)
+					printf("* due to symbol: %s\n", sym->name);
+				printf("*\n");
+			}
 			rootEntry = menu_get_parent_menu(menu);
 			conf(rootEntry);
 			break;