mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/5] console: provide veprintf and eputchar helpers
@ 2024-07-31  7:14 Ahmad Fatoum
  2024-07-31  7:14 ` [PATCH 2/5] KASan: report: print shadow memory state to stderr Ahmad Fatoum
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2024-07-31  7:14 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For easy printing to stderr, provide helpers that can be used instead of
vprintf and eputchar, respectively. To make them generally usable, also
provide stubs for PBL.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/console_common.c | 19 ++++++++++++++-----
 include/stdio.h         | 10 +++++++++-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/common/console_common.c b/common/console_common.c
index 0113a6413850..a8527eee1e5a 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -361,23 +361,32 @@ EXPORT_SYMBOL(of_console_get_by_alias);
 
 #endif /* !CONFIG_CONSOLE_NONE */
 
-int dprintf(int file, const char *fmt, ...)
+int vdprintf(int file, const char *fmt, va_list args)
 {
-	va_list args;
 	char printbuffer[CFG_PBSIZE];
 
-	va_start(args, fmt);
-
 	/*
 	 * For this to work, printbuffer must be larger than
 	 * anything we ever want to print.
 	 */
 	vsnprintf(printbuffer, sizeof(printbuffer), fmt, args);
-	va_end(args);
 
 	/* Print the string */
 	return dputs(file, printbuffer);
 }
+EXPORT_SYMBOL(vdprintf);
+
+int dprintf(int file, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = vdprintf(file, fmt, args);
+	va_end(args);
+
+	return i;
+}
 EXPORT_SYMBOL(dprintf);
 
 int dputs(int fd, const char *s)
diff --git a/include/stdio.h b/include/stdio.h
index d53f29039376..095e9b0a1d42 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -95,14 +95,22 @@ static inline void putchar(char c)
  * FILE based functions
  */
 
-/* stderr */
+#ifdef __PBL__
+#define eprintf			printf
+#define veprintf		vprintf
+#define eputchar		putchar
+#else
 #define eprintf(fmt,args...)	dprintf(STDERR_FILENO, fmt ,##args)
+#define veprintf(fmt,args)	vdprintf(STDERR_FILENO, fmt, args)
+#define eputchar(ch)		dputc(STDERR_FILENO, ch)
+#endif
 
 #define STDIN_FILENO		0
 #define STDOUT_FILENO		1
 #define STDERR_FILENO		2
 #define MAX_FILES	128
 
+int vdprintf(int fd, const char *fmt, va_list args) ;
 int dprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
 int dputs(int file, const char *s);
 int dputc(int file, const char c);
-- 
2.39.2




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

end of thread, other threads:[~2024-08-01 11:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-31  7:14 [PATCH 1/5] console: provide veprintf and eputchar helpers Ahmad Fatoum
2024-07-31  7:14 ` [PATCH 2/5] KASan: report: print shadow memory state to stderr Ahmad Fatoum
2024-07-31  7:14 ` [PATCH 3/5] ARM: print exception reports " Ahmad Fatoum
2024-07-31  7:14 ` [PATCH 4/5] common: print panic " Ahmad Fatoum
2024-07-31  7:14 ` [PATCH 5/5] RISC-V: stacktrace: output stack traces to standard error Ahmad Fatoum
2024-08-01 11:33 ` [PATCH 1/5] console: provide veprintf and eputchar helpers Sascha Hauer

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