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

* [PATCH 2/2] pbl: fix panic() message printing
  2026-02-26 11:07 [PATCH 1/2] pbl: console: implement vprintf() Sascha Hauer
@ 2026-02-26 11:07 ` Sascha Hauer
  2026-03-04  7:36 ` [PATCH 1/2] pbl: console: implement vprintf() Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-02-26 11:07 UTC (permalink / raw)
  To: Barebox List

printf() takes variadic arguments, not a va_list. Use vprintf() to
correctly print messages containing arguments.

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

diff --git a/pbl/misc.c b/pbl/misc.c
index 075c6a854b..c0e4473655 100644
--- a/pbl/misc.c
+++ b/pbl/misc.c
@@ -2,6 +2,7 @@
 
 #include <common.h>
 #include <init.h>
+#include <stdio.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
@@ -16,8 +17,9 @@ void __noreturn panic(const char *fmt, ...)
 	va_list args;
 
 	va_start(args, fmt);
-	printf(fmt, args);
+	vprintf(fmt, args);
 	va_end(args);
+
 	while(1);
 }
 
-- 
2.47.3




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

* Re: [PATCH 1/2] pbl: console: implement vprintf()
  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 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-03-04  7:36 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Thu, 26 Feb 2026 12:07:57 +0100, Sascha Hauer wrote:
> vprintf() can be used to implement printf() which is done in this patch,
> but will also be usable for panic() in the next patch.
> 
> 

Applied, thanks!

[1/2] pbl: console: implement vprintf()
      https://git.pengutronix.de/cgit/barebox/commit/?id=f626f1a9e049 (link may not be stable)
[2/2] pbl: fix panic() message printing
      https://git.pengutronix.de/cgit/barebox/commit/?id=33e3bc478232 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ 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