diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-06-19 15:20:13 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-06-21 08:42:55 +0900 |
commit | c6134d3e2f1d1d17b32b6e06556cd0c5429bc78a (patch) | |
tree | 14163e4dffb3f2b12dc3fe84e9d676d3521f53cd /src/nspawn/nspawn-cgroup.c | |
parent | f66ad46066a9911192f0b49eb06dae7dafc0c983 (diff) | |
download | systemd-c6134d3e2f1d1d17b32b6e06556cd0c5429bc78a.tar.gz |
path-util: get rid of prefix_root()
prefix_root() is equivalent to path_join() in almost all ways, hence
let's remove it.
There are subtle differences though: prefix_root() will try shorten
multiple "/" before and after the prefix. path_join() doesn't do that.
This means prefix_root() might return a string shorter than both its
inputs combined, while path_join() never does that. I like the
path_join() semantics better, hence I think dropping prefix_root() is
totally OK. In the end the strings generated by both functon should
always be identical in terms of path_equal() if not streq().
This leaves prefix_roota() in place. Ideally we'd have path_joina(), but
I don't think we can reasonably implement that as a macro. or maybe we
can? (if so, sounds like something for a later PR)
Also add in a few missing OOM checks
Diffstat (limited to 'src/nspawn/nspawn-cgroup.c')
-rw-r--r-- | src/nspawn/nspawn-cgroup.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c index f84bb39796..0462b46413 100644 --- a/src/nspawn/nspawn-cgroup.c +++ b/src/nspawn/nspawn-cgroup.c @@ -370,7 +370,7 @@ static int mount_legacy_cgns_supported( if (streq(controller, tok)) break; - target = prefix_root("/sys/fs/cgroup/", tok); + target = path_join("/sys/fs/cgroup/", tok); if (!target) return log_oom(); @@ -451,7 +451,7 @@ static int mount_legacy_cgns_unsupported( if (!controller) break; - origin = prefix_root("/sys/fs/cgroup/", controller); + origin = path_join("/sys/fs/cgroup/", controller); if (!origin) return log_oom(); @@ -468,7 +468,7 @@ static int mount_legacy_cgns_unsupported( else { _cleanup_free_ char *target = NULL; - target = prefix_root(dest, origin); + target = path_join(dest, origin); if (!target) return log_oom(); |