]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: add CMD_SYSERROR()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 16 Aug 2018 11:01:54 +0000 (13:01 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 16 Aug 2018 11:01:54 +0000 (13:01 +0200)
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 <christian.brauner@ubuntu.com>
src/lxc/log.h

index 734fbe17797da6d241448332172410b964f2a9be..d75d87d4329cf654c7c695177c66619707dfdad9 100644 (file)
@@ -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);