From: Richard Russon Date: Mon, 25 Feb 2019 23:59:04 +0000 (+0000) Subject: tidy mutt_menu_new() X-Git-Tag: 2019-10-25~354^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8966d1a9a72c44f1c19f4275568576a0bdf91b8d;p=neomutt tidy mutt_menu_new() Rename the function parameter and the local variable to be clearer. --- diff --git a/menu.c b/menu.c index 209662863..77176fe4e 100644 --- a/menu.c +++ b/menu.c @@ -969,30 +969,30 @@ void mutt_menu_init(void) /** * mutt_menu_new - Create a new Menu - * @param menu Menu type, e.g. #MENU_PAGER + * @param type Menu type, e.g. #MENU_PAGER * @retval ptr New Menu */ -struct Menu *mutt_menu_new(int menu) +struct Menu *mutt_menu_new(enum MenuType type) { - struct Menu *p = mutt_mem_calloc(1, sizeof(struct Menu)); - - if ((menu < 0) || (menu >= MENU_MAX)) - menu = MENU_GENERIC; - - p->menu = menu; - p->current = 0; - p->top = 0; - p->offset = 0; - p->redraw = REDRAW_FULL; - p->pagelen = MuttIndexWindow->rows; - p->indexwin = MuttIndexWindow; - p->statuswin = MuttStatusWindow; - p->helpwin = MuttHelpWindow; - p->messagewin = MuttMessageWindow; - p->menu_color = default_color; - p->menu_search = generic_search; - - return p; + struct Menu *menu = mutt_mem_calloc(1, sizeof(struct Menu)); + + if (type >= MENU_MAX) + type = MENU_GENERIC; + + menu->menu = type; + menu->current = 0; + menu->top = 0; + menu->offset = 0; + menu->redraw = REDRAW_FULL; + menu->pagelen = MuttIndexWindow->rows; + menu->indexwin = MuttIndexWindow; + menu->statuswin = MuttStatusWindow; + menu->helpwin = MuttHelpWindow; + menu->messagewin = MuttMessageWindow; + menu->menu_color = default_color; + menu->menu_search = generic_search; + + return menu; } /** diff --git a/mutt_menu.h b/mutt_menu.h index c5d9e3f42..9a8324113 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -27,6 +27,7 @@ #include #include #include "config/lib.h" +#include "keymap.h" /* These Config Variables are only used in menu.c */ extern short MenuContext; @@ -154,7 +155,7 @@ void mutt_menu_current_redraw(void); void mutt_menu_destroy(struct Menu **p); void mutt_menu_init(void); int mutt_menu_loop(struct Menu *menu); -struct Menu *mutt_menu_new(int menu); +struct Menu *mutt_menu_new(enum MenuType type); void mutt_menu_pop_current(struct Menu *menu); void mutt_menu_push_current(struct Menu *menu); void mutt_menu_set_current_redraw_full(void); diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index cdde37a4c..27fb0cad7 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -4631,7 +4631,7 @@ static struct CryptKeyInfo *crypt_select_key(struct CryptKeyInfo *keys, char helpstr[LONG_STRING], buf[LONG_STRING]; struct CryptKeyInfo *k = NULL; int (*f)(const void *, const void *); - int menu_to_use = 0; + enum MenuType menu_to_use = MENU_GENERIC; bool unusable = false; *forced_valid = 0;