summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGregor Herburger <[email protected]>2026-04-13 17:24:53 +0200
committerTom Rini <[email protected]>2026-04-22 14:23:49 -0600
commit2c8fdd7aea1d3c6c380ea5b5080147dc7fe9c38f (patch)
tree266330ba84691d7cbdabeab1f38ba7fd712c2aed /lib
parent3abc7c1d46de4211b2d11051033566c9ad2c2740 (diff)
console: add console_flush_stdin()
Add a common helper console_flush_stdin() to drain all pending characters from stdin. This consolidates the open-coded while (tstc()) getchar() pattern that appeared in multiple places across the tree. Signed-off-by: Gregor Herburger <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]> Reviewed-by: Quentin Schulz <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_console.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index a798d5604a3..8d076058280 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -9,6 +9,7 @@
#include <ansi.h>
#include <charset.h>
+#include <console.h>
#include <efi_device_path.h>
#include <malloc.h>
#include <time.h>
@@ -299,8 +300,7 @@ static int query_console_serial(int *rows, int *cols)
int n[2];
/* Empty input buffer */
- while (tstc())
- getchar();
+ console_flush_stdin();
/*
* Not all terminals understand CSI [18t for querying the console size.
@@ -960,8 +960,7 @@ static void efi_cin_check(void)
*/
static void efi_cin_empty_buffer(void)
{
- while (tstc())
- getchar();
+ console_flush_stdin();
key_available = false;
}