kconfig: rename menu_get_parent_menu() to menu_get_menu_or_parent_menu()

The current menu_get_parent_menu() does not always return the parent
menu; if the given argument is itself a menu, it returns that menu.

Rename this function to better reflect this behavior.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
This commit is contained in:
Masahiro Yamada 2025-06-25 00:04:52 +09:00
parent 604f5b2127
commit 3c292cd004
4 changed files with 12 additions and 6 deletions

View File

@ -594,7 +594,7 @@ static void check_conf(struct menu *menu)
default: default:
if (!conf_cnt++) if (!conf_cnt++)
printf("*\n* Restart config...\n*\n"); printf("*\n* Restart config...\n*\n");
rootEntry = menu_get_parent_menu(menu); rootEntry = menu_get_menu_or_parent_menu(menu);
conf(rootEntry); conf(rootEntry);
break; break;
} }

View File

@ -97,7 +97,7 @@ bool menu_is_empty(struct menu *menu);
bool menu_is_visible(struct menu *menu); bool menu_is_visible(struct menu *menu);
bool menu_has_prompt(const struct menu *menu); bool menu_has_prompt(const struct menu *menu);
const char *menu_get_prompt(const struct menu *menu); const char *menu_get_prompt(const struct menu *menu);
struct menu *menu_get_parent_menu(struct menu *menu); struct menu *menu_get_menu_or_parent_menu(struct menu *menu);
int get_jump_key_char(void); int get_jump_key_char(void);
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
void menu_get_ext_help(struct menu *menu, struct gstr *help); void menu_get_ext_help(struct menu *menu, struct gstr *help);

View File

@ -575,7 +575,13 @@ const char *menu_get_prompt(const struct menu *menu)
return NULL; return NULL;
} }
struct menu *menu_get_parent_menu(struct menu *menu) /**
* menu_get_menu_or_parent_menu - return the parent menu or the menu itself
* @menu: pointer to the menu
* return: the parent menu. If the given argument is already a menu, return
* itself.
*/
struct menu *menu_get_menu_or_parent_menu(struct menu *menu)
{ {
enum prop_type type; enum prop_type type;

View File

@ -577,7 +577,7 @@ void ConfigList::setParentMenu(void)
oldroot = rootEntry; oldroot = rootEntry;
if (rootEntry == &rootmenu) if (rootEntry == &rootmenu)
return; return;
setRootMenu(menu_get_parent_menu(rootEntry->parent)); setRootMenu(menu_get_menu_or_parent_menu(rootEntry->parent));
QTreeWidgetItemIterator it(this); QTreeWidgetItemIterator it(this);
while (*it) { while (*it) {
@ -1540,7 +1540,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
switch (configList->mode) { switch (configList->mode) {
case singleMode: case singleMode:
list = configList; list = configList;
parent = menu_get_parent_menu(menu); parent = menu_get_menu_or_parent_menu(menu);
if (!parent) if (!parent)
return; return;
list->setRootMenu(parent); list->setRootMenu(parent);
@ -1551,7 +1551,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
configList->clearSelection(); configList->clearSelection();
list = configList; list = configList;
} else { } else {
parent = menu_get_parent_menu(menu->parent); parent = menu_get_menu_or_parent_menu(menu->parent);
if (!parent) if (!parent)
return; return;