diff options
Diffstat (limited to 'src/shared/install-printf.c')
-rw-r--r-- | src/shared/install-printf.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c index 3cc7093..bdb44b3 100644 --- a/src/shared/install-printf.c +++ b/src/shared/install-printf.c @@ -37,16 +37,11 @@ static int specifier_prefix_and_instance(char specifier, const void *data, const static int specifier_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) { const InstallInfo *i = ASSERT_PTR(userdata); - char *ans; if (unit_name_is_valid(i->name, UNIT_NAME_TEMPLATE) && i->default_instance) return unit_name_replace_instance(i->name, i->default_instance, ret); - ans = strdup(i->name); - if (!ans) - return -ENOMEM; - *ret = ans; - return 0; + return strdup_to(ret, i->name); } static int specifier_prefix(char specifier, const void *data, const char *root, const void *userdata, char **ret) { @@ -86,14 +81,10 @@ static int specifier_last_component(char specifier, const void *data, const char return r; dash = strrchr(prefix, '-'); - if (dash) { - dash = strdup(dash + 1); - if (!dash) - return -ENOMEM; - *ret = dash; - } else - *ret = TAKE_PTR(prefix); + if (dash) + return strdup_to(ret, dash + 1); + *ret = TAKE_PTR(prefix); return 0; } |