[PATCH 02/10] sandbox: Correct loss of early output in SPL

Simon Glass sjg at chromium.org
Sun Mar 27 22:26:14 CEST 2022


At present fputc() is used before the console is available, then write()
is used. These are not compatible. Since fputc() buffers internally it is
better to use the write(), so that a partial line is immediately
displayed.

This has a slight effect on performance, but we are already using write()
for the vast majority of the output with no obvious impacts.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/sandbox/cpu/os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index d83c862182d..5ea54179176 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -644,7 +644,7 @@ int os_get_filesize(const char *fname, long long *size)
 
 void os_putc(int ch)
 {
-	fputc(ch, stdout);
+	os_write(1, &ch, 1);
 }
 
 void os_puts(const char *str)
-- 
2.35.1.1021.g381101b075-goog



More information about the U-Boot mailing list