diff mbox series

[v2,1/3] lib/vsprintf.c: implement printf() in terms of vprintf()

Message ID 20210527222046.1276246-2-rasmus.villemoes@prevas.dk
State Accepted
Commit 97587786463ae3a44c95fcb053ab27136c646aa3
Delegated to: Tom Rini
Headers show
Series trivial printf patches | expand

Commit Message

Rasmus Villemoes May 27, 2021, 10:20 p.m. UTC
This saves some code, both in terms of #LOC and .text size, and it is
also the normal convention that foo(...) is implemented in terms of
vfoo().

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 lib/vsprintf.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Tom Rini July 16, 2021, 3:52 p.m. UTC | #1
On Fri, May 28, 2021 at 12:20:44AM +0200, Rasmus Villemoes wrote:

> This saves some code, both in terms of #LOC and .text size, and it is
> also the normal convention that foo(...) is implemented in terms of
> vfoo().
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

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

Patch

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 9dc96c81c6..cf3982eb03 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -787,22 +787,11 @@  int printf(const char *fmt, ...)
 {
 	va_list args;
 	uint i;
-	char printbuffer[CONFIG_SYS_PBSIZE];
 
 	va_start(args, fmt);
-
-	/*
-	 * For this to work, printbuffer must be larger than
-	 * anything we ever want to print.
-	 */
-	i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
+	i = vprintf(fmt, args);
 	va_end(args);
 
-	/* Handle error */
-	if (i <= 0)
-		return i;
-	/* Print the string */
-	puts(printbuffer);
 	return i;
 }