lib/vsprintf.c: implement printf() in terms of vprintf()
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Thu, 27 May 2021 22:20:44 +0000 (00:20 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 15 Jul 2021 22:44:36 +0000 (18:44 -0400)
This saves some code, both in terms of #LOC and .text size, and it is
also the normal convention that foo(...) is implemented in terms of
vfoo().

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
lib/vsprintf.c

index 9dc96c8..cf3982e 100644 (file)
@@ -787,22 +787,11 @@ int printf(const char *fmt, ...)
 {
        va_list args;
        uint i;
-       char printbuffer[CONFIG_SYS_PBSIZE];
 
        va_start(args, fmt);
-
-       /*
-        * For this to work, printbuffer must be larger than
-        * anything we ever want to print.
-        */
-       i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
+       i = vprintf(fmt, args);
        va_end(args);
 
-       /* Handle error */
-       if (i <= 0)
-               return i;
-       /* Print the string */
-       puts(printbuffer);
        return i;
 }