summaryrefslogtreecommitdiffstats
path: root/src/basic/cgroup-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/cgroup-util.c')
-rw-r--r--src/basic/cgroup-util.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 947fb900d6..ca697ed97a 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -978,6 +978,7 @@ int cg_is_empty_recursive(const char *controller, const char *path) {
int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
_cleanup_free_ char *controller = NULL, *path = NULL;
+ int r;
assert(spec);
@@ -986,11 +987,9 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
return -EINVAL;
if (ret_path) {
- path = strdup(spec);
- if (!path)
- return -ENOMEM;
-
- path_simplify(path);
+ r = path_simplify_alloc(spec, &path);
+ if (r < 0)
+ return r;
}
} else {
@@ -1037,22 +1036,14 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
int cg_mangle_path(const char *path, char **result) {
_cleanup_free_ char *c = NULL, *p = NULL;
- char *t;
int r;
assert(path);
assert(result);
/* First, check if it already is a filesystem path */
- if (path_startswith(path, "/sys/fs/cgroup")) {
-
- t = strdup(path);
- if (!t)
- return -ENOMEM;
-
- *result = path_simplify(t);
- return 0;
- }
+ if (path_startswith(path, "/sys/fs/cgroup"))
+ return path_simplify_alloc(path, result);
/* Otherwise, treat it as cg spec */
r = cg_split_spec(path, &c, &p);