]> xenbits.xensource.com Git - libvirt.git/commitdiff
vircgroupv1: refactor virCgroupV1DetectPlacement
authorPavel Hrdina <phrdina@redhat.com>
Wed, 4 Nov 2020 18:46:24 +0000 (19:46 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 10 Feb 2021 12:37:12 +0000 (13:37 +0100)
Remove one level of indentation by splitting the condition.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/vircgroupv1.c

index edb2c23bbcf6a30ef9c84fec6ee7ea23e312ec43..f4dd20fd73aac658c41815a27171b34fe5dd8778 100644 (file)
@@ -339,23 +339,28 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
         const char *typestr = virCgroupV1ControllerTypeToString(i);
 
-        if (virCgroupV1MountOptsMatchController(controllers, typestr) &&
-            group->legacy[i].mountPoint != NULL &&
-            group->legacy[i].placement == NULL) {
-            /*
-             * selfpath == "/" + path="" -> "/"
-             * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
-             * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
-             */
-            if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
-                group->legacy[i].placement = g_strdup(selfpath);
-            } else {
-                bool delim = STREQ(selfpath, "/") || STREQ(path, "");
-
-                group->legacy[i].placement = g_strdup_printf("%s%s%s", selfpath,
-                                                             delim ? "" : "/",
-                                                             path);
-            }
+        if (!virCgroupV1MountOptsMatchController(controllers, typestr))
+            continue;
+
+        if (!group->legacy[i].mountPoint)
+            continue;
+
+        if (group->legacy[i].placement)
+            continue;
+
+        /*
+         * selfpath == "/" + path="" -> "/"
+         * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
+         * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
+         */
+        if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
+            group->legacy[i].placement = g_strdup(selfpath);
+        } else {
+            bool delim = STREQ(selfpath, "/") || STREQ(path, "");
+
+            group->legacy[i].placement = g_strdup_printf("%s%s%s", selfpath,
+                                                         delim ? "" : "/",
+                                                         path);
         }
     }