diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2018-02-26 13:03:40 +1030 |
---|---|---|
committer | Andrew Jeffery <andrew@aj.id.au> | 2018-03-19 10:55:29 +1030 |
commit | 44ac078b2a310cb4f18ed2d885c0d4edd2ee0f14 (patch) | |
tree | 8c8dc641bc110d2f230adc2cafda15805eb9ffc1 /common.c | |
parent | 7a3814b0f063e0d85fb3e4226cbfc7d174a13c9b (diff) | |
download | phosphor-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.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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); |