diff options
author | Simon Glass <sjg@chromium.org> | 2018-06-11 13:07:14 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-07-09 09:11:00 -0600 |
commit | b616cef97aa8562a8c08558505675e255b5347cc (patch) | |
tree | dce9df5e72db11e292306f38b3dae5effad0cf72 /include/log.h | |
parent | c60f671b65a8b336c3533fcf0f0ee45dff287ff7 (diff) |
log: Add a way to log a return value with a message
It is sometimes useful to show a message when logging an error return
value, perhaps to add a few details about the problem. Add a function to
support this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/log.h')
-rw-r--r-- | include/log.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/log.h b/include/log.h index 3e99d6e62b..653fb8d853 100644 --- a/include/log.h +++ b/include/log.h @@ -166,8 +166,16 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line, log(LOG_CATEGORY, LOGL_ERR, "returning err=%d\n", __ret); \ __ret; \ }) +#define log_msg_ret(_msg, _ret) ({ \ + int __ret = (_ret); \ + if (__ret < 0) \ + log(LOG_CATEGORY, LOGL_ERR, "%s: returning err=%d\n", _msg, \ + __ret); \ + __ret; \ + }) #else #define log_ret(_ret) (_ret) +#define log_msg_ret(_ret) (_ret) #endif /** |