]> granicus.if.org Git - neomutt/commitdiff
tidy mutt_menu_new()
authorRichard Russon <rich@flatcap.org>
Mon, 25 Feb 2019 23:59:04 +0000 (23:59 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 27 Feb 2019 15:17:43 +0000 (15:17 +0000)
Rename the function parameter and the local variable to be clearer.

menu.c
mutt_menu.h
ncrypt/crypt_gpgme.c

diff --git a/menu.c b/menu.c
index 209662863abe10be13baba0adc0cf168a1c18f98..77176fe4e3de982f83408de39ef3535bd8a66cd6 100644 (file)
--- 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;
 }
 
 /**
index c5d9e3f42881daf8684ea2a07269683ddf98dd45..9a8324113a0135ce19d72486cf258a36a8f783b7 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #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);
index cdde37a4c1874eaa393a659788e68bd2ed98ead4..27fb0cad7ede51a97db77851f7ff39a67d1fd1d4 100644 (file)
@@ -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;