util-lib: introduce new empty_or_root() helper (#8746)

We check the same condition at various places. Let's add a trivial,
common helper for this, and use it everywhere.

It's not going to make things much faster or much shorter, but I think a
lot more readable
This commit is contained in:
Lennart Poettering
2018-04-18 14:20:49 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 12777909c9
commit 57ea45e11a
11 changed files with 50 additions and 18 deletions
+2 -2
View File
@@ -421,7 +421,7 @@ int cg_migrate(
* exist in the root cgroup, we only check for
* them there. */
if (cfrom &&
(isempty(pfrom) || path_equal(pfrom, "/")) &&
empty_or_root(pfrom) &&
is_kernel_thread(pid) > 0)
continue;
@@ -1185,7 +1185,7 @@ int cg_is_empty_recursive(const char *controller, const char *path) {
assert(path);
/* The root cgroup is always populated */
if (controller && (isempty(path) || path_equal(path, "/")))
if (controller && empty_or_root(path))
return false;
r = cg_unified_controller(controller);