]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
menu: Use a switch statement
authorSimon Glass <sjg@chromium.org>
Fri, 6 Jan 2023 14:52:25 +0000 (08:52 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 16 Jan 2023 19:14:11 +0000 (14:14 -0500)
Convert the long line of if() statements to a switch() since this makes
better use of the C language.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/menu.c

index 6842f5409d6eb2224f8ff61bcad9aac0dce0e383..7db98942a610e111a166b532f07a7b56b1daffa7 100644 (file)
@@ -543,22 +543,31 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc)
                break;
        }
 
-       /* enter key was pressed */
-       if (c == '\r')
+       switch (c) {
+       case '\r':
+               /* enter key was pressed */
                key = BKEY_SELECT;
-
-       /* ^C was pressed */
-       if (c == 0x3)
+               break;
+       case CTL_CH('c'):
+               /* ^C was pressed */
                key = BKEY_QUIT;
-
-       if (c == '+')
+               break;
+       case CTL_CH('p'):
+               key = BKEY_UP;
+               break;
+       case CTL_CH('n'):
+               key = BKEY_DOWN;
+               break;
+       case '+':
                key = BKEY_PLUS;
-
-       if (c == '-')
+               break;
+       case '-':
                key = BKEY_MINUS;
-
-       if (c == ' ')
+               break;
+       case ' ':
                key = BKEY_SPACE;
+               break;
+       }
 
        return key;
 }