mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +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:
parent
2c52204c3f
commit
8f9364f98b
@ -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) {
|
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);
|
assert(p);
|
||||||
if (!e)
|
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;
|
return NULL;
|
||||||
|
|
||||||
/* Make sure the returned path starts with a slash */
|
e--;
|
||||||
if (e[0] != '/') {
|
|
||||||
if (e == path || e[-1] != '/')
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
e--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int path_is_generator(const LookupPaths *p, const char *path) {
|
static int path_is_generator(const LookupPaths *p, const char *path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user