summaryrefslogtreecommitdiff
path: root/src/test/test-conf-files.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-06-19 15:20:13 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-06-21 08:42:55 +0900
commitc6134d3e2f1d1d17b32b6e06556cd0c5429bc78a (patch)
tree14163e4dffb3f2b12dc3fe84e9d676d3521f53cd /src/test/test-conf-files.c
parentf66ad46066a9911192f0b49eb06dae7dafc0c983 (diff)
downloadsystemd-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/test/test-conf-files.c')
-rw-r--r--src/test/test-conf-files.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/test-conf-files.c b/src/test/test-conf-files.c
index 9fd8b6b590..07b681cf43 100644
--- a/src/test/test-conf-files.c
+++ b/src/test/test-conf-files.c
@@ -102,11 +102,11 @@ static void test_conf_files_insert(const char *root) {
char **dirs = STRV_MAKE("/dir1", "/dir2", "/dir3");
_cleanup_free_ const char
- *foo1 = prefix_root(root, "/dir1/foo.conf"),
- *foo2 = prefix_root(root, "/dir2/foo.conf"),
- *bar2 = prefix_root(root, "/dir2/bar.conf"),
- *zzz3 = prefix_root(root, "/dir3/zzz.conf"),
- *whatever = prefix_root(root, "/whatever.conf");
+ *foo1 = path_join(root, "/dir1/foo.conf"),
+ *foo2 = path_join(root, "/dir2/foo.conf"),
+ *bar2 = path_join(root, "/dir2/bar.conf"),
+ *zzz3 = path_join(root, "/dir3/zzz.conf"),
+ *whatever = path_join(root, "/whatever.conf");
assert_se(conf_files_insert(&s, root, dirs, "/dir2/foo.conf") == 0);
assert_se(strv_equal(s, STRV_MAKE(foo2)));