diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-04-18 14:20:49 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-18 14:20:49 +0200 |
commit | 57ea45e11a3856a110cf195628f8b26cfe019a15 (patch) | |
tree | 900a35ca836367027c812d0829bf7cf2f508e9b1 /src/basic/path-util.h | |
parent | 12777909c9cbf4217aecbbb38de97bac5252fc5b (diff) | |
download | systemd-57ea45e11a3856a110cf195628f8b26cfe019a15.tar.gz |
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.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 7ec0a3eb0f..fa8f8e4eab 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -111,7 +111,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; \ @@ -155,3 +155,5 @@ static inline const char *skip_dev_prefix(const char *p) { return e ?: p; } + +bool empty_or_root(const char *root); |