summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-06-03 15:19:47 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-06-11 17:29:02 +0000
commitdeb99af8a1bff0ca66cf5764570d5f8e2033039b (patch)
tree3cb48f05a9cb79d3c60c9b5f65fcacd10aa7f6da /src
parent913437e8a268130b7fbfb9d6d366c42de4f681be (diff)
downloadcoreboot-deb99af8a1bff0ca66cf5764570d5f8e2033039b.tar.xz
console: Allow using vprintk() with disabled console
The prototype of vprintk() is currently declared unconditionally, which prevents it from being used in situations where the console is disabled. The code will compile correctly, but not link, since the definition in console.c isn't being provided. This adds a shim around the declaration so that, like printk(), a call to vprintk() in this situation will expand to a no-op function instead. Change-Id: Ib4a9aa96a5b9dbb9b937ff45854bf6a407938b37 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Reviewed-on: https://review.coreboot.org/c/coreboot/+/33181 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/console/printk.c4
-rw-r--r--src/include/console/console.h9
2 files changed, 7 insertions, 6 deletions
diff --git a/src/console/printk.c b/src/console/printk.c
index 09522158a7..8606bbb5c9 100644
--- a/src/console/printk.c
+++ b/src/console/printk.c
@@ -45,7 +45,7 @@ static void wrap_putchar_cbmemc(unsigned char byte, void *data)
__cbmemc_tx_byte(byte);
}
-int vprintk(int msg_level, const char *fmt, va_list args)
+int do_vprintk(int msg_level, const char *fmt, va_list args)
{
int i, log_this;
@@ -91,7 +91,7 @@ int do_printk(int msg_level, const char *fmt, ...)
int i;
va_start(args, fmt);
- i = vprintk(msg_level, fmt, args);
+ i = do_vprintk(msg_level, fmt, args);
va_end(args);
return i;
diff --git a/src/include/console/console.h b/src/include/console/console.h
index 369ce5be00..e5b753e8b6 100644
--- a/src/include/console/console.h
+++ b/src/include/console/console.h
@@ -63,8 +63,8 @@ asmlinkage void console_init(void);
int console_log_level(int msg_level);
void do_putchar(unsigned char byte);
-#define printk(LEVEL, fmt, args...) \
- do { do_printk(LEVEL, fmt, ##args); } while (0)
+#define printk(LEVEL, fmt, args...) do_printk(LEVEL, fmt, ##args)
+#define vprintk(LEVEL, fmt, args) do_vprintk(LEVEL, fmt, args)
enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL };
@@ -84,14 +84,15 @@ static inline int get_console_loglevel(void)
static inline void console_init(void) {}
static inline int console_log_level(int msg_level) { return 0; }
static inline void printk(int LEVEL, const char *fmt, ...) {}
+static inline void vprintk(int LEVEL, const char *fmt, va_list args) {}
static inline void do_putchar(unsigned char byte) {}
#endif
-int vprintk(int msg_level, const char *fmt, va_list args);
-
int do_printk(int msg_level, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
+int do_vprintk(int msg_level, const char *fmt, va_list args);
+
#endif /* !__ROMCC__ */
#endif /* CONSOLE_CONSOLE_H_ */