From: Thomas Parrott Date: Tue, 21 May 2019 16:25:52 +0000 (+0100) Subject: lxc/log: Adds error_log_errno macro X-Git-Tag: lxc-3.2.0~3^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e7d1bd171de081d4dbcc944993d7ad068ce9647;p=thirdparty%2Flxc.git lxc/log: Adds error_log_errno macro Suggested usage: return error_log_errno(err, "Failed: %s", "some error"); It sets errno to the value of err, then calls SYSERROR with the format and remaining args. It always returns -1. Suggested-by: Christian Brauner Signed-off-by: Thomas Parrott --- diff --git a/src/lxc/log.h b/src/lxc/log.h index 5afe4e093..8b093de90 100644 --- a/src/lxc/log.h +++ b/src/lxc/log.h @@ -505,6 +505,13 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \ } while (0) #endif +#define error_log_errno(__errno__, format, ...) \ + ({ \ + errno = __errno__; \ + SYSERROR(format, ##__VA_ARGS__); \ + -1; \ + }) + extern int lxc_log_fd; extern int lxc_log_syslog(int facility);