[PATCH v5 04/17] menu: menu_get_choice() return -ENOENT if menu item is empty

Heinrich Schuchardt xypron.glpk at gmx.de
Fri Apr 29 21:38:36 CEST 2022


On 4/28/22 10:09, Masahisa Kojima wrote:
> menu_get_choice() needs to handle the case that menu item
> is empty. In this case, menu_get_choice() returns -ENOENT.
>
> Signed-off-by: Masahisa Kojima <masahisa.kojima at linaro.org>
> ---
> Newly created in v5
>
>   common/menu.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/common/menu.c b/common/menu.c
> index b577d80b4f..4118c6dc3c 100644
> --- a/common/menu.c
> +++ b/common/menu.c
> @@ -271,6 +271,9 @@ int menu_get_choice(struct menu *m, void **choice)
>   	if (!m || !choice)
>   		return -EINVAL;
>
> +	if (m->item_cnt == 0)

nits:

We tend to use (!m->item_cnt).

Best regards

Heinrich

> +		return -ENOENT;
> +
>   	if (!m->prompt)
>   		return menu_default_choice(m, choice);
>



More information about the U-Boot mailing list