]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/unit-printf: port to unit_get_cgroup_path_with_fallback()
authorMike Yuan <me@yhndnzj.com>
Wed, 4 Jun 2025 18:30:59 +0000 (20:30 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 4 Jun 2025 20:03:48 +0000 (22:03 +0200)
src/core/unit-printf.c

index 2b35a1b2a9263cba2798e948299523d8ec240e99..7c8bf991507232fb44f0d1e1b8850caa2671b04d 100644 (file)
@@ -88,14 +88,10 @@ static void bad_specifier(const Unit *u, char specifier) {
 
 static int specifier_cgroup(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
         const Unit *u = ASSERT_PTR(userdata);
-        CGroupRuntime *crt = unit_get_cgroup_runtime(u);
 
         bad_specifier(u, specifier);
 
-        if (crt && crt->cgroup_path)
-                return strdup_to(ret, crt->cgroup_path);
-
-        return unit_default_cgroup_path(u, ret);
+        return unit_get_cgroup_path_with_fallback(u, ret);
 }
 
 static int specifier_cgroup_root(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
@@ -112,14 +108,8 @@ static int specifier_cgroup_slice(char specifier, const void *data, const char *
         bad_specifier(u, specifier);
 
         slice = UNIT_GET_SLICE(u);
-        if (slice) {
-                CGroupRuntime *crt = unit_get_cgroup_runtime(slice);
-
-                if (crt && crt->cgroup_path)
-                        return strdup_to(ret, crt->cgroup_path);
-
-                return unit_default_cgroup_path(slice, ret);
-        }
+        if (slice)
+                return unit_get_cgroup_path_with_fallback(slice, ret);
 
         return strdup_to(ret, u->manager->cgroup_root);
 }