tiny-printf: Correct the snprintf() implementation
authorSimon Glass <sjg@chromium.org>
Thu, 9 Jun 2016 02:55:15 +0000 (20:55 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 9 Jun 2016 17:52:53 +0000 (13:52 -0400)
This current code passes the variable arguments list to sprintf(). This is
not correct. Fix it by calling _vprintf() directly.

This makes firefly-rk3288 boot again.

Fixes: abeb272 ("tiny-printf: Support snprintf()")
Reviewed-by: Stefan Roese <sr@denx.de>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
lib/tiny-printf.c

index 5ea2555280b1561da6e072d6d8092b9e2b2325f3..3c65fc90bf233bdfe0d5ffd1b77e8a4842a5de4d 100644 (file)
@@ -168,8 +168,10 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
        int ret;
 
        va_start(va, fmt);
-       ret = sprintf(buf, fmt, va);
+       outstr = buf;
+       ret = _vprintf(fmt, va, putc_outstr);
        va_end(va);
+       *outstr = '\0';
 
        return ret;
 }