mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] pbl: console: implement vprintf()
@ 2026-02-26 11:07 Sascha Hauer
  2026-02-26 11:07 ` [PATCH 2/2] pbl: fix panic() message printing Sascha Hauer
  2026-03-04  7:36 ` [PATCH 1/2] pbl: console: implement vprintf() Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-02-26 11:07 UTC (permalink / raw)
  To: Barebox List

vprintf() can be used to implement printf() which is done in this patch,
but will also be usable for panic() in the next patch.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 pbl/console.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/pbl/console.c b/pbl/console.c
index 6665232014..f2e7b3a20e 100644
--- a/pbl/console.c
+++ b/pbl/console.c
@@ -56,18 +56,32 @@ int console_puts(unsigned int ch, const char *str)
 	return n;
 }
 
+int vprintf(const char *fmt, va_list args)
+{
+	int i;
+	char printbuffer[CFG_PBSIZE];
+
+	/*
+	 * For this to work, printbuffer must be larger than
+	 * anything we ever want to print.
+	 */
+	i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args);
+
+	/* Print the string */
+	console_puts(CONSOLE_STDOUT, printbuffer);
+
+	return i;
+}
+
 int printf(const char *fmt, ...)
 {
 	va_list args;
 	uint i;
-	char printbuffer[CFG_PBSIZE];
 
 	va_start(args, fmt);
-	i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args);
+	i = vprintf(fmt, args);
 	va_end(args);
 
-	console_puts(CONSOLE_STDOUT, printbuffer);
-
 	return i;
 }
 
-- 
2.47.3




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-04  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26 11:07 [PATCH 1/2] pbl: console: implement vprintf() Sascha Hauer
2026-02-26 11:07 ` [PATCH 2/2] pbl: fix panic() message printing Sascha Hauer
2026-03-04  7:36 ` [PATCH 1/2] pbl: console: implement vprintf() Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox