[U-Boot] [PATCH 1/2] tiny-printf: Support sprintf()

Marek Vasut marex at denx.de
Tue May 31 23:12:46 CEST 2016


Add a simple version of this function for SPL. It does not check the buffer
size as this would add to the code size.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Simon Glass <sjg at chromium.org>
Cc: Stefan Roese <sr at denx.de>
Cc: Tom Rini <trini at konsulko.com>
Cc: lesne at alse-fr.com
---
 lib/tiny-printf.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 4b70263..5ea2555 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -147,8 +147,7 @@ static void putc_outstr(char ch)
 	*outstr++ = ch;
 }
 
-/* Note that size is ignored */
-int snprintf(char *buf, size_t size, const char *fmt, ...)
+int sprintf(char *buf, const char *fmt, ...)
 {
 	va_list va;
 	int ret;
@@ -161,3 +160,16 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
 
 	return ret;
 }
+
+/* Note that size is ignored */
+int snprintf(char *buf, size_t size, const char *fmt, ...)
+{
+	va_list va;
+	int ret;
+
+	va_start(va, fmt);
+	ret = sprintf(buf, fmt, va);
+	va_end(va);
+
+	return ret;
+}
-- 
2.7.0



More information about the U-Boot mailing list