mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
core: check for redundant operation before doing allocation
This commit is contained in:
parent
cbe83389d5
commit
5210387ea6
@ -1568,15 +1568,14 @@ int unit_set_cgroup_path(Unit *u, const char *path) {
|
||||
|
||||
assert(u);
|
||||
|
||||
if (streq_ptr(u->cgroup_path, path))
|
||||
return 0;
|
||||
|
||||
if (path) {
|
||||
p = strdup(path);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
} else
|
||||
p = NULL;
|
||||
|
||||
if (streq_ptr(u->cgroup_path, p))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p) {
|
||||
r = hashmap_put(u->manager->cgroup_unit, p, u);
|
||||
@ -1585,7 +1584,6 @@ int unit_set_cgroup_path(Unit *u, const char *path) {
|
||||
}
|
||||
|
||||
unit_release_cgroup(u);
|
||||
|
||||
u->cgroup_path = TAKE_PTR(p);
|
||||
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user