summaryrefslogtreecommitdiffstats
path: root/common.c
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-02-26 13:03:40 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-19 10:55:29 +1030
commit44ac078b2a310cb4f18ed2d885c0d4edd2ee0f14 (patch)
tree8c8dc641bc110d2f230adc2cafda15805eb9ffc1 /common.c
parent7a3814b0f063e0d85fb3e4226cbfc7d174a13c9b (diff)
downloadphosphor-mboxd-44ac078b2a310cb4f18ed2d885c0d4edd2ee0f14.tar.gz
phosphor-mboxd-44ac078b2a310cb4f18ed2d885c0d4edd2ee0f14.zip
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>
Diffstat (limited to 'common.c')
-rw-r--r--common.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/common.c b/common.c
index c460815..540cec5 100644
--- a/common.c
+++ b/common.c
@@ -45,8 +45,19 @@ void mbox_log_console(int p, const char *fmt, va_list args)
__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);
OpenPOWER on IntegriCloud