summaryrefslogtreecommitdiff
path: root/src/basic/path-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-04-18 14:20:49 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commite5e0c80fdfa8861931df799574d5a60c96b6aa13 (patch)
tree3ff055d308feb83a85c3d8a2edd0eb9ebcfd42a4 /src/basic/path-util.h
parentd1dbf40d47cfa883c4c9fa264dfd84cd57a03b85 (diff)
util-lib: introduce new empty_or_root() helper (#8746)
We check the same condition at various places. Let's add a trivial, common helper for this, and use it everywhere. It's not going to make things much faster or much shorter, but I think a lot more readable
Diffstat (limited to 'src/basic/path-util.h')
-rw-r--r--src/basic/path-util.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/basic/path-util.h b/src/basic/path-util.h
index 08df54573..6583c2c9b 100644
--- a/src/basic/path-util.h
+++ b/src/basic/path-util.h
@@ -121,7 +121,7 @@ char *prefix_root(const char *root, const char *path);
size_t _l; \
while (_path[0] == '/' && _path[1] == '/') \
_path ++; \
- if (isempty(_root) || path_equal(_root, "/")) \
+ if (empty_or_root(_root)) \
_ret = _path; \
else { \
_l = strlen(_root) + 1 + strlen(_path) + 1; \
@@ -169,3 +169,5 @@ static inline const char *skip_dev_prefix(const char *p) {
return e ?: p;
}
+
+bool empty_or_root(const char *root);