From: Zbigniew Jędrzejewski-Szmek Date: Wed, 12 Dec 2018 23:57:16 +0000 (+0100) Subject: shared/install: remove two conditionals which are always false X-Git-Tag: v240~52^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2eded6cb2c5a7aebfafc77f9a23c1f6900da362c;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/install.c b/src/shared/install.c index de8044b28fa..ebc56a4aa63 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;