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/shared/install.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/shared/install.c')
-rw-r--r-- | src/shared/install.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/install.c b/src/shared/install.c index 5391ac702b..b13b1f6d9e 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -794,7 +794,7 @@ static int find_symlinks_fd( if (!path_is_absolute(dest)) { char *x; - x = prefix_root(root_dir, dest); + x = path_join(root_dir, dest); if (!x) return -ENOMEM; @@ -1377,7 +1377,7 @@ static int unit_file_load_or_readlink( if (path_is_absolute(target)) /* This is an absolute path, prefix the root so that we always deal with fully qualified paths */ - info->symlink_target = prefix_root(root_dir, target); + info->symlink_target = path_join(root_dir, target); else /* This is a relative path, take it relative to the dir the symlink is located in. */ info->symlink_target = file_in_same_dir(path, target); @@ -2188,7 +2188,7 @@ int unit_file_link( if (!unit_name_is_valid(fn, UNIT_NAME_ANY)) return -EINVAL; - full = prefix_root(paths.root_dir, *i); + full = path_join(paths.root_dir, *i); if (!full) return -ENOMEM; |