basic/group-util: optimize alloca use

Follow-up for 0fa7b50053.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-03-11 14:43:16 +01:00
parent bcef0f33cc
commit e4645ca599
2 changed files with 11 additions and 7 deletions
+5 -7
View File
@@ -533,14 +533,12 @@ static int controller_is_v1_accessible(const char *root, const char *controller)
assert(controller);
dn = controller_to_dirname(controller);
cpath = strjoina("/sys/fs/cgroup/", dn);
if (root)
/* Also check that:
* - possible subcgroup is created at root,
* - we can modify the hierarchy.
* "Leak" cpath on stack */
cpath = strjoina(cpath, root, "/cgroup.procs");
/* If root if specified, we check that:
* - possible subcgroup is created at root,
* - we can modify the hierarchy. */
cpath = strjoina("/sys/fs/cgroup/", dn, root, root ? "/cgroup.procs" : NULL);
if (laccess(cpath, root ? W_OK : F_OK) < 0)
return -errno;