From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/2] pbl: console: implement vprintf()
Date: Thu, 26 Feb 2026 12:07:57 +0100 [thread overview]
Message-ID: <20260226110758.505072-1-s.hauer@pengutronix.de> (raw)
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
next reply other threads:[~2026-02-26 11:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 11:07 Sascha Hauer [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226110758.505072-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox