From fe2d4d4cef093d24da389fda29a556b15c84829b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 2 Apr 2025 06:29:32 +1300 Subject: 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 Reviewed-by: Alexander Sverdlin --- include/console.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/console.h b/include/console.h index 57fdb0834c1..8d0d7bb8a4c 100644 --- a/include/console.h +++ b/include/console.h @@ -169,6 +169,21 @@ int console_announce_r(void); */ void console_puts_select_stderr(bool serial_only, const char *s); +/** + * console_printf_select_stderr() - Output a formatted string to selected devs + * + * This writes to stderr only. It is useful for outputting errors. Note that it + * uses its own buffer, separate from the print buffer, to allow printing + * messages within console/stdio code + * + * @serial_only: true to output only to serial, false to output to everything + * else + * @fmt: Printf format string, followed by format arguments + * Return: number of characters written + */ +int console_printf_select_stderr(bool serial_only, const char *fmt, ...) + __attribute__ ((format (__printf__, 2, 3))); + /** * console_clear() - Clear the console * -- cgit v1.2.3