summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-09-20 12:07:16 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2017-09-26 08:48:46 +0200
commit0b8f3441aa032b69770f59cafc37087a6d505cee (patch)
tree4583a56f279f92530f6a80430635581368a9a1b6
parentb2ac13f498fb217194d6afe836981411bf14158c (diff)
downloadbarebox-0b8f3441aa032b69770f59cafc37087a6d505cee.tar.gz
console_countdown: ignore errors in getchar()
The getchar() call may return an error reported as a -1, e.g. when the console detects a RATP message and switches to RATP mode. In general it probably is a good idea to ignore these errors in the console countdown operation; and in particular for the RATP usecase, this also prevents from interfering with the countdown and menu just when switching one of the consoles to RATP mode. As a hint, this is what the standard console was printing due to this issue when the RATP console was activated: Hit m for menu or any other key to stop autoboot: [: missing `]' Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/console_countdown.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/common/console_countdown.c b/common/console_countdown.c
index 03b9b33..36da1ce 100644
--- a/common/console_countdown.c
+++ b/common/console_countdown.c
@@ -47,12 +47,14 @@ int console_countdown(int timeout_s, unsigned flags, char *out_key)
do {
if (tstc()) {
key = getchar();
- if (flags & CONSOLE_COUNTDOWN_ANYKEY)
- goto out;
- if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n')
- goto out;
- if (flags & CONSOLE_COUNTDOWN_CTRLC && key == 3)
- goto out;
+ if (key >= 0) {
+ if (flags & CONSOLE_COUNTDOWN_ANYKEY)
+ goto out;
+ if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n')
+ goto out;
+ if (flags & CONSOLE_COUNTDOWN_CTRLC && key == 3)
+ goto out;
+ }
key = 0;
}
if ((flags & CONSOLE_COUNTDOWN_EXTERN) &&