Skip to contentSkip to conversation

tiny-printf: Correct the snprintf() implementation

PATCH New Simon Glass 4 participants 4 messages Jun 9, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tiny-printf: Correct the snprintf() implementation

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()")

---

Changes in v2:
- Correct the 'Fixes' line

 lib/tiny-printf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/tiny-printf.c +3 -1
index 5ea2555..3c65fc9 100644
@@ -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;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v2 1/1 tiny-printf: Correct the snprintf() implementation

Quoted 7 lines · Simon Glass

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()")

Thanks,
Stefan

#2 lore raw

PATCH v2 1/1 tiny-printf: Correct the snprintf() implementation

Quoted 11 lines · Stefan Roese
Quoted 8 lines · Simon Glass

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()")
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH v2 1/1 tiny-printf: Correct the snprintf() implementation

In reply to Simon Glass
Quoted 9 lines · Simon Glass

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()")

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160609/80f56a2f/attachment.sig>