diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-04-08 17:58:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-12 13:43:32 +0200 |
commit | 8f9364f98b3816ac90308b198030ba958757bb9b (patch) | |
tree | 935cd63bb0a70acb8c7209efae79b52d3e071694 /src/shared | |
parent | 2c52204c3f615df482d42e5c27d609fd8cb16a7a (diff) |
install: simplify skip_root() a bit
Exit early, so that we can get rid of the large if block.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/install.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/shared/install.c b/src/shared/install.c index 3d48f612f3..3289b51f41 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -85,25 +85,27 @@ static int in_search_path(const LookupPaths *p, const char *path) { } static const char* skip_root(const LookupPaths *p, const char *path) { - if (p->root_dir) { - char *e; + char *e; - e = path_startswith(path, p->root_dir); - if (!e) - return NULL; + assert(p); + assert(path); - /* Make sure the returned path starts with a slash */ - if (e[0] != '/') { - if (e == path || e[-1] != '/') - return NULL; + if (!p->root_dir) + return path; - e--; - } + e = path_startswith(path, p->root_dir); + if (!e) + return NULL; + + /* Make sure the returned path starts with a slash */ + if (e[0] != '/') { + if (e == path || e[-1] != '/') + return NULL; - return e; + e--; } - return path; + return e; } static int path_is_generator(const LookupPaths *p, const char *path) { |