summaryrefslogtreecommitdiffstats
path: root/common.h
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.h
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.h')
-rw-r--r--common.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/common.h b/common.h
index 90a0fc9..20dbf1a 100644
--- a/common.h
+++ b/common.h
@@ -26,23 +26,34 @@
#endif
enum verbose {
- MBOX_LOG_NONE = 0,
- MBOX_LOG_INFO = 1,
- MBOX_LOG_DEBUG = 2
+ MBOX_LOG_NONE = 0,
+ MBOX_LOG_INFO = 1,
+ MBOX_LOG_DEBUG = 2
};
extern enum verbose verbosity;
/* Error Messages */
-#define MSG_ERR(f_, ...) mbox_log(LOG_ERR, f_, ##__VA_ARGS__)
+#define MSG_ERR(f_, ...) \
+do { \
+ mbox_log(LOG_ERR, f_, ##__VA_ARGS__); \
+} while (0)
+
/* Informational Messages */
-#define MSG_INFO(f_, ...) do { if (verbosity >= MBOX_LOG_INFO) { \
- mbox_log(LOG_INFO, f_, ##__VA_ARGS__); \
- } } while (0)
+#define MSG_INFO(f_, ...) \
+do { \
+ if (verbosity >= MBOX_LOG_INFO) { \
+ mbox_log(LOG_INFO, f_, ##__VA_ARGS__); \
+ } \
+} while (0)
+
/* Debug Messages */
-#define MSG_DBG(f_, ...) do { if (verbosity >= MBOX_LOG_DEBUG) { \
- mbox_log(LOG_DEBUG, f_, ##__VA_ARGS__); \
- } } while(0)
+#define MSG_DBG(f_, ...) \
+do { \
+ if (verbosity >= MBOX_LOG_DEBUG) { \
+ mbox_log(LOG_DEBUG, f_, ##__VA_ARGS__); \
+ } \
+} while(0)
extern void (*mbox_vlog)(int p, const char *fmt, va_list args);
OpenPOWER on IntegriCloud