common: Improve readability and utility of MSG_*() macros
Ensures we can't dereference NULL if a logger hasn't been set, and
cleans up the MSG_*() macros for readability.
Change-Id: I9808d8fe7672613e90c705686d1eaf1e2edef38a
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/common.c b/common.c
index c460815..540cec5 100644
--- a/common.c
+++ b/common.c
@@ -45,8 +45,19 @@
__attribute__((format(printf, 2, 3)))
void mbox_log(int p, const char *fmt, ...)
{
+ static bool warned = false;
va_list args;
+ if (!mbox_vlog) {
+ if (!warned) {
+ fprintf(stderr, "Logging backend not configured, "
+ "log output disabled\n");
+ warned = true;
+ }
+
+ return;
+ }
+
va_start(args, fmt);
mbox_vlog(p, fmt, args);
va_end(args);