]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/path-util.c
path-util: get rid of prefix_root()
authorLennart Poettering <lennart@poettering.net>
Wed, 19 Jun 2019 13:20:13 +0000 (15:20 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jun 2019 23:42:55 +0000 (08:42 +0900)
commitc6134d3e2f1d1d17b32b6e06556cd0c5429bc78a
tree14163e4dffb3f2b12dc3fe84e9d676d3521f53cd
parentf66ad46066a9911192f0b49eb06dae7dafc0c983
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
14 files changed:
src/basic/conf-files.c
src/basic/path-util.c
src/basic/path-util.h
src/core/namespace.c
src/cryptsetup/cryptsetup-generator.c
src/nspawn/nspawn-cgroup.c
src/nspawn/nspawn-mount.c
src/nspawn/nspawn.c
src/shared/dev-setup.c
src/shared/install.c
src/shared/path-lookup.c
src/test/test-conf-files.c
src/test/test-path-util.c
src/tmpfiles/tmpfiles.c