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:
committed by
Zbigniew Jędrzejewski-Szmek
parent
12777909c9
commit
57ea45e11a
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user