1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

install: simplify skip_root() a bit

Exit early, so that we can get rid of the large if block.
This commit is contained in:
Lennart Poettering 2016-04-08 17:58:53 +02:00
parent 2c52204c3f
commit 8f9364f98b

View File

@ -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)
assert(p);
assert(path);
if (!p->root_dir)
return path;
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;
/* Make sure the returned path starts with a slash */
if (e[0] != '/') {
if (e == path || e[-1] != '/')
return NULL;
e--;
}
return e;
e--;
}
return path;
return e;
}
static int path_is_generator(const LookupPaths *p, const char *path) {