From: Christian Brauner Date: Thu, 25 Feb 2021 23:45:39 +0000 (+0100) Subject: tree-wide: replace old-style sysinfo logging return helper X-Git-Tag: lxc-5.0.0~266^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=815c378b9b3044849149f481cb406343c0f3b900;p=thirdparty%2Flxc.git tree-wide: replace old-style sysinfo logging return helper Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 5497a85be..46ed69714 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -3063,7 +3063,7 @@ static bool unified_hierarchy_delegated(int dfd_base, char ***ret_files) if (!faccessat(dfd_base, *s, W_OK, 0) || errno == ENOENT) continue; - return sysinfo(false, "The %s file is not writable, skipping unified hierarchy", *s); + return sysinfo_ret(false, "The %s file is not writable, skipping unified hierarchy", *s); } *ret_files = move_ptr(list); @@ -3073,7 +3073,7 @@ static bool unified_hierarchy_delegated(int dfd_base, char ***ret_files) static bool legacy_hierarchy_delegated(int dfd_base) { if (faccessat(dfd_base, "cgroup.procs", W_OK, 0) && errno != ENOENT) - return sysinfo(false, "The cgroup.procs file is not writable, skipping legacy hierarchy"); + return sysinfo_ret(false, "The cgroup.procs file is not writable, skipping legacy hierarchy"); return true; } diff --git a/src/lxc/log.h b/src/lxc/log.h index 1bf12e166..27690bba3 100644 --- a/src/lxc/log.h +++ b/src/lxc/log.h @@ -494,13 +494,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \ __internal_ret__; \ }) -#define sysinfo(__ret__, format, ...) \ - ({ \ - typeof(__ret__) __internal_ret__ = (__ret__); \ - SYSINFO(format, ##__VA_ARGS__); \ - __internal_ret__; \ - }) - #define log_error(__ret__, format, ...) \ ({ \ typeof(__ret__) __internal_ret__ = (__ret__); \ @@ -611,6 +604,27 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \ __internal_ret__; \ }) +#define sysinfo(format, ...) \ + ({ \ + SYSINFO(format, ##__VA_ARGS__); \ + (-errno); \ + }) + +#define sysinfo_set(__ret__, format, ...) \ + ({ \ + typeof(__ret__) __internal_ret__ = (__ret__); \ + errno = labs(__ret__); \ + SYSINFO(format, ##__VA_ARGS__); \ + __internal_ret__; \ + }) + +#define sysinfo_ret(__ret__, format, ...) \ + ({ \ + typeof(__ret__) __internal_ret__ = (__ret__); \ + SYSINFO(format, ##__VA_ARGS__); \ + __internal_ret__; \ + }) + #define sysdebug(format, ...) \ ({ \ SYSDEBUG(format, ##__VA_ARGS__); \