[lxc-devel] [lxc/master] Use %m instead of strerror() when available
Rachid-Koucha on Github
lxc-bot at linuxcontainers.org
Mon May 13 12:47:38 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 407 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190513/4e210e48/attachment.bin>
-------------- next part --------------
From a1d652c25b11e3eb51001bb9d9605d75537d9f40 Mon Sep 17 00:00:00 2001
From: Rachid Koucha <47061324+Rachid-Koucha at users.noreply.github.com>
Date: Mon, 13 May 2019 13:21:14 +0200
Subject: [PATCH] Use %m instead of strerror() when available
Use %m under HAVE_M_FORMAT instead of strerror()
Signed-off-by: Rachid Koucha <rachid.koucha at gmail.com>
---
src/lxc/log.h | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/src/lxc/log.h b/src/lxc/log.h
index 3b7557edbd..4ced2d7506 100644
--- a/src/lxc/log.h
+++ b/src/lxc/log.h
@@ -416,53 +416,94 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
LXC_FATAL(&locinfo, format, ##__VA_ARGS__); \
} while (0)
+#if HAVE_M_FORMAT
+#define SYSTRACE(format, ...) \
+ TRACE("%m - " format, ##__VA_ARGS__);
+#else
#define SYSTRACE(format, ...) \
do { \
lxc_log_strerror_r; \
TRACE("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+#if HAVE_M_FORMAT
+#define SYSDEBUG(format, ...) \
+ DEBUG("%m - " format, ##__VA_ARGS__)
+#else
#define SYSDEBUG(format, ...) \
do { \
lxc_log_strerror_r; \
DEBUG("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+
+#if HAVE_M_FORMAT
+#define SYSINFO(format, ...) \
+ INFO("%m - " format, ##__VA_ARGS__)
+#else
#define SYSINFO(format, ...) \
do { \
lxc_log_strerror_r; \
INFO("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+#if HAVE_M_FORMAT
+#define SYSNOTICE(format, ...) \
+ NOTICE("%m - " format, ##__VA_ARGS__)
+#else
#define SYSNOTICE(format, ...) \
do { \
lxc_log_strerror_r; \
NOTICE("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+#if HAVE_M_FORMAT
+#define SYSWARN(format, ...) \
+ WARN("%m - " format, ##__VA_ARGS__)
+#else
#define SYSWARN(format, ...) \
do { \
lxc_log_strerror_r; \
WARN("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+#if HAVE_M_FORMAT
+#define SYSERROR(format, ...) \
+ ERROR("%m - " format, ##__VA_ARGS__)
+#else
#define SYSERROR(format, ...) \
do { \
lxc_log_strerror_r; \
ERROR("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+#if HAVE_M_FORMAT
+#define CMD_SYSERROR(format, ...) \
+ fprintf(stderr, "%m - " format, ##__VA_ARGS__)
+#else
#define CMD_SYSERROR(format, ...) \
do { \
lxc_log_strerror_r; \
fprintf(stderr, "%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
+#if HAVE_M_FORMAT
+#define CMD_SYSINFO(format, ...) \
+ printf("%m - " format, ##__VA_ARGS__)
+#else
#define CMD_SYSINFO(format, ...) \
do { \
lxc_log_strerror_r; \
printf("%s - " format, ptr, ##__VA_ARGS__); \
} while (0)
+#endif
extern int lxc_log_fd;
More information about the lxc-devel
mailing list