common: rename getc() to getchar()
The sandbox is built with the SDL2 library with invokes the X11 library
which in turn calls getc(). But getc() in glibc is defined as
int getc(FILE *)
This does not match our definition.
int getc(void)
The sandbox crashes when called with parameter -l.
Rename our library symbol getc() to getchar().
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/common/autoboot.c b/common/autoboot.c
index 74f97a0..e628baf 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -117,7 +117,7 @@
return 0;
}
- presskey[presskey_len++] = getc();
+ presskey[presskey_len++] = getchar();
/* Calculate sha256 upon each new char */
hash_block(algo_name, (const void *)presskey,
@@ -189,12 +189,12 @@
do {
if (tstc()) {
if (presskey_len < presskey_max) {
- presskey[presskey_len++] = getc();
+ presskey[presskey_len++] = getchar();
} else {
for (i = 0; i < presskey_max - 1; i++)
presskey[i] = presskey[i + 1];
- presskey[i] = getc();
+ presskey[i] = getchar();
}
}
@@ -257,7 +257,7 @@
* Check if key already pressed
*/
if (tstc()) { /* we got a key press */
- (void) getc(); /* consume input */
+ getchar(); /* consume input */
puts("\b\b\b 0");
abort = 1; /* don't auto boot */
}
@@ -272,7 +272,7 @@
abort = 1; /* don't auto boot */
bootdelay = 0; /* no more delay */
- key = getc(); /* consume input */
+ key = getchar();/* consume input */
if (IS_ENABLED(CONFIG_USE_AUTOBOOT_MENUKEY))
menukey = key;
break;
diff --git a/common/cli_readline.c b/common/cli_readline.c
index 1f1e28c..47b8762 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -68,7 +68,7 @@
#define CREAD_HIST_CHAR ('!')
#define getcmd_putch(ch) putc(ch)
-#define getcmd_getch() getc()
+#define getcmd_getch() getchar()
#define getcmd_cbeep() getcmd_putch('\a')
#define HIST_MAX 20
@@ -571,7 +571,7 @@
return -2; /* timed out */
WATCHDOG_RESET(); /* Trigger watchdog, if needed */
- c = getc();
+ c = getchar();
/*
* Special character handling
diff --git a/common/console.c b/common/console.c
index 8e50af1..3348436 100644
--- a/common/console.c
+++ b/common/console.c
@@ -131,7 +131,7 @@
*/
switch (file) {
case stdin:
- gd->jt->getc = getc;
+ gd->jt->getc = getchar;
gd->jt->tstc = tstc;
break;
case stdout:
@@ -179,7 +179,7 @@
int cd_count[MAX_FILES];
/*
- * This depends on tstc() always being called before getc().
+ * This depends on tstc() always being called before getchar().
* This is guaranteed to be true because this routine is called
* only from fgetc() which assures it.
* No attempt is made to demultiplex multiple input sources.
@@ -404,7 +404,7 @@
/** U-Boot INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/
-int getc(void)
+int getchar(void)
{
#ifdef CONFIG_DISABLE_CONSOLE
if (gd->flags & GD_FLG_DISABLE_CONSOLE)
@@ -663,7 +663,7 @@
{
if (!ctrlc_disabled && gd->have_console) {
if (tstc()) {
- switch (getc()) {
+ switch (getchar()) {
case 0x03: /* ^C - Control C */
ctrlc_was_pressed = 1;
return 1;
@@ -685,10 +685,10 @@
/* Flush input */
while (tstc())
- getc();
+ getchar();
i = 0;
while (i < sizeof(str_input)) {
- str_input[i] = getc();
+ str_input[i] = getchar();
putc(str_input[i]);
if (str_input[i] == '\r')
break;
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 2845124..e979f78 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -32,7 +32,7 @@
static int getcymodem(void) {
if (tstc())
- return (getc());
+ return (getchar());
return -1;
}
diff --git a/common/xyzModem.c b/common/xyzModem.c
index 6bf2375..fc3459e 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -72,7 +72,7 @@
}
if (tstc ())
{
- *c = getc ();
+ *c = getchar();
return 1;
}
return 0;