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

index 5497a85beee3f097887408dbb6c57e907304a228..46ed69714f6d2e31afc074763afc047292a6a6c3 100644 (file)
@@ -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;
 }
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__); \