From: Christian Brauner Date: Thu, 16 Aug 2018 11:01:54 +0000 (+0200) Subject: log: add CMD_SYSERROR() X-Git-Tag: lxc-3.1.0~157^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb9623e70582bc734244acd91edee9d0b43fd6be;p=thirdparty%2Flxc.git log: add CMD_SYSERROR() Add a thread-safe and uniform way to retrieve errno values in programs that are shipped as part of LXC but are not expected to have access to the logging system. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/log.h b/src/lxc/log.h index 734fbe177..d75d87d43 100644 --- a/src/lxc/log.h +++ b/src/lxc/log.h @@ -429,6 +429,12 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \ ERROR("%s - " format, ptr, ##__VA_ARGS__); \ } while (0) +#define CMD_SYSERROR(format, ...) \ + do { \ + lxc_log_strerror_r; \ + fprintf(stderr, "%s - " format, ptr, ##__VA_ARGS__); \ + } while (0) + extern int lxc_log_fd; extern int lxc_log_syslog(int facility);