tiny-printf: Support sprintf()

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@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: lesne@alse-fr.com
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Sylvain Lesne <lesne@alse-fr.com>
Tested-by: Sylvain Lesne <lesne@alse-fr.com>
This commit is contained in:
Marek Vasut 2016-05-31 23:12:46 +02:00 committed by Tom Rini
parent b4ba1693ef
commit abeb272d22

View file

@ -147,8 +147,7 @@ static void putc_outstr(char ch)
*outstr++ = ch; *outstr++ = ch;
} }
/* Note that size is ignored */ int sprintf(char *buf, const char *fmt, ...)
int snprintf(char *buf, size_t size, const char *fmt, ...)
{ {
va_list va; va_list va;
int ret; int ret;
@ -161,3 +160,16 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
return ret; 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;
}