]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tree-wide: replace old-style sysinfo logging return helper
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 25 Feb 2021 23:45:39 +0000 (00:45 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Feb 2021 20:47:46 +0000 (21:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/log.h

index 733f6b974822fb499e1c63c3b5f786d44f23f61a..37c140e2043162a99d9d0b3e99b8497410ab30f9 100644 (file)
@@ -3061,7 +3061,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);
@@ -3071,7 +3071,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;
 }
index 1bf12e166c4f55d7d508e24a6b98a8ae3c00e8b7..27690bba317101e0555c0db4233f933821bd1193 100644 (file)
@@ -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__); \