diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-02-09 20:08:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-09 20:08:58 +0100 |
commit | a09d3eafac72435e87ad34a4129a4c414b684e3e (patch) | |
tree | c0b6d7ec2cea571b5ef87520fe9f483d7f93b2da | |
parent | 96bb2fd8bdd0533399ab3798ea0b23548f81b667 (diff) |
dropin: let's reduce duplicate a bit
After generating the template name we can shortcut things and just call
unit_file_find_dirs() from inside itself, just with the new name and
save a good number of duplicate lines.
-rw-r--r-- | src/shared/dropin.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 0f29c5c457..d645a6a5ba 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -164,22 +164,15 @@ static int unit_file_find_dirs( } if (unit_name_is_valid(name, UNIT_NAME_INSTANCE)) { - _cleanup_free_ char *template = NULL, *p = NULL; /* Also try the template dir */ + _cleanup_free_ char *template = NULL; + r = unit_name_template(name, &template); if (r < 0) return log_error_errno(r, "Failed to generate template from unit name: %m"); - p = strjoin(unit_path, "/", template, suffix); - if (!p) - return log_oom(); - - if (!unit_path_cache || set_get(unit_path_cache, p)) { - r = unit_file_find_dir(original_root, p, dirs); - if (r < 0) - return r; - } + return unit_file_find_dirs(original_root, unit_path_cache, unit_path, template, suffix, dirs); } return 0; |