autoboot: Adjust the implementation in autoboot_command()
authorSimon Glass <sjg@chromium.org>
Sun, 21 Jul 2019 02:51:28 +0000 (20:51 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 2 Aug 2019 15:19:14 +0000 (11:19 -0400)
Avoid use of #ifdef and keep the common condion in a variable. This makes
the code easier to read.

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

index 75132f8697f82f77e489ad4df525006d2a48d32e..42fbd7614a8126d92a35325c8fbbd0bb3be18786 100644 (file)
@@ -349,15 +349,18 @@ void autoboot_command(const char *s)
        debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
 
        if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) {
-#if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC)
-               int prev = disable_ctrlc(1);    /* disable Control C checking */
-#endif
+               bool lock;
+               int prev;
+
+               lock = IS_ENABLED(CONFIG_AUTOBOOT_KEYED) &&
+                       !IS_ENABLED(CONFIG_AUTOBOOT_KEYED_CTRLC);
+               if (lock)
+                       prev = disable_ctrlc(1); /* disable Ctrl-C checking */
 
                run_command_list(s, -1, 0);
 
-#if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC)
-               disable_ctrlc(prev);    /* restore Control C checking */
-#endif
+               if (lock)
+                       disable_ctrlc(prev);    /* restore Ctrl-C checking */
        }
 
        if (IS_ENABLED(CONFIG_USE_AUTOBOOT_MENUKEY) &&