diff mbox

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

Message ID 1464729167-5409-1-git-send-email-marex@denx.de
State Accepted
Commit abeb272d22217481c214495818c3ceabad57b9c0
Delegated to: Tom Rini
Headers show

Commit Message

Marek Vasut May 31, 2016, 9:12 p.m. UTC
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
---
 lib/tiny-printf.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Tom Rini May 31, 2016, 10:55 p.m. UTC | #1
On Tue, May 31, 2016 at 11:12:46PM +0200, Marek Vasut wrote:

> 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>
Sylvain Lesne June 1, 2016, 8:16 a.m. UTC | #2
Hi,

On 05/31/2016 11:12 PM, Marek Vasut wrote:
> 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

This is how I would do it as well, and I can confirm that it builds
and boots on a socfpga platform (sockit), when using part_dos.c
(that includes sprintf() calls).

Reviewed-by: Sylvain Lesne <lesne@alse-fr.com>
Tested-by: Sylvain Lesne <lesne@alse-fr.com>
Tom Rini June 3, 2016, 2 p.m. UTC | #3
On Tue, May 31, 2016 at 11:12:46PM +0200, Marek Vasut wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox

Patch

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;
+}