From a88996cc6c72a6f7fd034c0890747c54cc377484 Mon Sep 17 00:00:00 2001
Message-Id: <a88996cc6c72a6f7fd034c0890747c54cc377484@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Fri, 19 Feb 2021 13:33:56 +0100
Subject: [PATCH] vircgroupv1: refactor virCgroupV1DetectPlacement
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Remove one level of indentation by splitting the condition.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 5f56dd7c83493f14a471bb9e33415b04329a08bf)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <ce477880853d3a9988389789611b68c458834600.1613737828.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/vircgroupv1.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 7ec8f3a316..09165ece4d 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -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);
}
}
--
2.30.0