diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-12-13 00:57:16 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-12-13 00:58:27 +0100 |
commit | 2eded6cb2c5a7aebfafc77f9a23c1f6900da362c (patch) | |
tree | c73dd7ea35e5d416a826d30d6aade107cbe61968 /src | |
parent | shared/install: mark UnitFileInstallInfo* as const where appropriate (diff) | |
download | systemd-2eded6cb2c5a7aebfafc77f9a23c1f6900da362c.tar.gz systemd-2eded6cb2c5a7aebfafc77f9a23c1f6900da362c.tar.bz2 systemd-2eded6cb2c5a7aebfafc77f9a23c1f6900da362c.zip |
shared/install: remove two conditionals which are always false
The name argument in UnitFileInstallInfo (i->name) should always be a unit
file name, so the conditional always takes the 'else' branch.
The only call chain that links to find_symlinks_fd() is unit_file_lookup_state
→ find_symlinks_in_scope → find_symlinks → find_symlinks_fd. But
unit_file_lookup_state calls unit_name_is_valid(name), and then name is used
to construct the UnitFileInstallInfo object in install_info_discover, which just
uses the name it was given.
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/install.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/shared/install.c b/src/shared/install.c index de8044b28..ebc56a4aa 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -794,23 +794,15 @@ static int find_symlinks_fd( if (!x) return -ENOMEM; - free(dest); - dest = x; + free_and_replace(dest, x); } - /* Check if the symlink itself matches what we - * are looking for */ - if (path_is_absolute(i->name)) - found_path = path_equal(p, i->name); - else - found_path = streq(de->d_name, i->name); + /* Check if the symlink itself matches what we are looking for */ + assert(unit_name_is_valid(i->name, UNIT_NAME_ANY)); + found_path = streq(de->d_name, i->name); - /* Check if what the symlink points to - * matches what we are looking for */ - if (path_is_absolute(i->name)) - found_dest = path_equal(dest, i->name); - else - found_dest = streq(basename(dest), i->name); + /* Check if what the symlink points to matches what we are looking for */ + found_dest = streq(basename(dest), i->name); if (found_path && found_dest) { _cleanup_free_ char *t = NULL; |