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.koj...@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);