X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fbootmenu.c;h=3dc2c854aca5c4b7c54bd99b692beaa29360254f;hb=61b29b82683863a970fd4609a7c58512872616bc;hp=5879065c2ea45cc7b9731884aad1aa9a95128340;hpb=2e192b245ed36a63bab0ef576999a95e23f60ecd;p=oweals%2Fu-boot.git diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 5879065c2e..3dc2c854ac 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -1,12 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2011-2013 Pali Rohár - * - * SPDX-License-Identifier: GPL-2.0+ */ #include #include #include +#include #include #include #include @@ -53,7 +53,7 @@ static char *bootmenu_getoption(unsigned short int n) return NULL; sprintf(name, "bootmenu_%d", n); - return getenv(name); + return env_get(name); } static void bootmenu_print_entry(void *data) @@ -254,6 +254,7 @@ static struct bootmenu_data *bootmenu_create(int delay) int len; char *sep; + char *default_str; struct bootmenu_entry *entry; menu = malloc(sizeof(struct bootmenu_data)); @@ -264,6 +265,10 @@ static struct bootmenu_data *bootmenu_create(int delay) menu->active = 0; menu->first = NULL; + default_str = env_get("bootmenu_default"); + if (default_str) + menu->active = (int)simple_strtol(default_str, NULL, 10); + while ((option = bootmenu_getoption(i))) { sep = strchr(option, '='); if (!sep) { @@ -347,6 +352,12 @@ static struct bootmenu_data *bootmenu_create(int delay) } menu->count = i; + + if ((menu->active >= menu->count)||(menu->active < 0)) { //ensure active menuitem is inside menu + printf("active menuitem (%d) is outside menu (0..%d)\n",menu->active,menu->count-1); + menu->active=0; + } + return menu; cleanup: @@ -462,7 +473,7 @@ void menu_display_statusline(struct menu *m) puts(ANSI_CLEAR_LINE); } -#ifdef CONFIG_MENU_SHOW +#ifdef CONFIG_AUTOBOOT_MENU_SHOW int menu_show(int bootdelay) { bootmenu_show(bootdelay); @@ -483,7 +494,7 @@ int do_bootmenu(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) delay_str = argv[1]; if (!delay_str) - delay_str = getenv("bootmenu_delay"); + delay_str = env_get("bootmenu_delay"); if (delay_str) delay = (int)simple_strtol(delay_str, NULL, 10);