summaryrefslogtreecommitdiff
path: root/common/console.c
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-04-02 06:29:32 +1300
committerTom Rini <[email protected]>2025-05-02 13:40:20 -0600
commitfe2d4d4cef093d24da389fda29a556b15c84829b (patch)
tree9f7af11a4eaa84befd12bd19f2d75378e9de6811 /common/console.c
parent4ca87fd18c1b718be423755939a6e5b1688869f5 (diff)
console: Support a format string for stderr output
Add a console_printf_select_stderr() function so that it is not necessary for the caller to process the format string. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c
index 275da2f264d..48586fd2166 100644
--- a/common/console.c
+++ b/common/console.c
@@ -359,6 +359,24 @@ void console_puts_select_stderr(bool serial_only, const char *s)
console_puts_select(stderr, serial_only, s);
}
+int console_printf_select_stderr(bool serial_only, const char *fmt, ...)
+{
+ char buf[CONFIG_SYS_PBSIZE];
+ va_list args;
+ int ret;
+
+ va_start(args, fmt);
+
+ /* For this to work, buf must be larger than anything we ever want to
+ * print.
+ */
+ ret = vscnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+ console_puts_select_stderr(serial_only, buf);
+
+ return ret;
+}
+
static void console_puts(int file, const char *s)
{
int i;