Now that every caller to copyPlacement doesn't pass absolute path there is no need to have a condition to handle that case. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/util/vircgroupv1.c | 26 ++++++++++++-------------- src/util/vircgroupv2.c | 25 +++++++++++-------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index ed4b0813f2..731e9d61d4 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -190,26 +190,24 @@ virCgroupV1CopyPlacement(virCgroupPtr group, { size_t i; for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + bool delim; + if (!group->legacy[i].mountPoint) continue; if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) continue; - if (path[0] == '/') { - group->legacy[i].placement = g_strdup(path); - } else { - bool delim = STREQ(parent->legacy[i].placement, "/") || STREQ(path, ""); - /* - * parent == "/" + path="" => "/" - * parent == "/libvirt.service" + path == "" => "/libvirt.service" - * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" - */ - group->legacy[i].placement = g_strdup_printf("%s%s%s", - parent->legacy[i].placement, - delim ? "" : "/", - path); - } + delim = STREQ(parent->legacy[i].placement, "/") || STREQ(path, ""); + /* + * parent == "/" + path="" => "/" + * parent == "/libvirt.service" + path == "" => "/libvirt.service" + * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" + */ + group->legacy[i].placement = g_strdup_printf("%s%s%s", + parent->legacy[i].placement, + delim ? "" : "/", + path); } return 0; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 8e058ca9c6..2b32f614e4 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -149,22 +149,19 @@ virCgroupV2CopyPlacement(virCgroupPtr group, const char *path, virCgroupPtr parent) { + bool delim = STREQ(parent->unified.placement, "/") || STREQ(path, ""); + VIR_DEBUG("group=%p path=%s parent=%p", group, path, parent); - if (path[0] == '/') { - group->unified.placement = g_strdup(path); - } else { - bool delim = STREQ(parent->unified.placement, "/") || STREQ(path, ""); - /* - * parent == "/" + path="" => "/" - * parent == "/libvirt.service" + path == "" => "/libvirt.service" - * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" - */ - group->unified.placement = g_strdup_printf("%s%s%s", - parent->unified.placement, - delim ? "" : "/", - path); - } + /* + * parent == "/" + path="" => "/" + * parent == "/libvirt.service" + path == "" => "/libvirt.service" + * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" + */ + group->unified.placement = g_strdup_printf("%s%s%s", + parent->unified.placement, + delim ? "" : "/", + path); return 0; } -- 2.26.2