summaryrefslogtreecommitdiff
path: root/src/core/unit-printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/unit-printf.c')
-rw-r--r--src/core/unit-printf.c55
1 files changed, 13 insertions, 42 deletions
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index 5513fe7d9c..8050e2fd66 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -30,83 +30,54 @@
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
Unit *u = userdata;
- char *n;
assert(u);
- n = unit_name_to_prefix_and_instance(u->id);
- if (!n)
- return -ENOMEM;
-
- *ret = n;
- return 0;
+ return unit_name_to_prefix_and_instance(u->id, ret);
}
static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) {
Unit *u = userdata;
- char *n;
assert(u);
- n = unit_name_to_prefix(u->id);
- if (!n)
- return -ENOMEM;
-
- *ret = n;
- return 0;
+ return unit_name_to_prefix(u->id, ret);
}
static int specifier_prefix_unescaped(char specifier, void *data, void *userdata, char **ret) {
- Unit *u = userdata;
_cleanup_free_ char *p = NULL;
- char *n;
+ Unit *u = userdata;
+ int r;
assert(u);
- p = unit_name_to_prefix(u->id);
- if (!p)
- return -ENOMEM;
-
- n = unit_name_unescape(p);
- if (!n)
- return -ENOMEM;
+ r = unit_name_to_prefix(u->id, &p);
+ if (r < 0)
+ return r;
- *ret = n;
- return 0;
+ return unit_name_unescape(p, ret);
}
static int specifier_instance_unescaped(char specifier, void *data, void *userdata, char **ret) {
Unit *u = userdata;
- char *n;
assert(u);
if (!u->instance)
- return -EOPNOTSUPP;
-
- n = unit_name_unescape(u->instance);
- if (!n)
- return -ENOMEM;
+ return -EINVAL;
- *ret = n;
- return 0;
+ return unit_name_unescape(u->instance, ret);
}
static int specifier_filename(char specifier, void *data, void *userdata, char **ret) {
Unit *u = userdata;
- char *n;
assert(u);
if (u->instance)
- n = unit_name_path_unescape(u->instance);
+ return unit_name_path_unescape(u->instance, ret);
else
- n = unit_name_to_path(u->id);
- if (!n)
- return -ENOMEM;
-
- *ret = n;
- return 0;
+ return unit_name_to_path(u->id, ret);
}
static int specifier_cgroup(char specifier, void *data, void *userdata, char **ret) {
@@ -195,7 +166,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
c = unit_get_exec_context(u);
if (!c)
- return -EOPNOTSUPP;
+ return -EINVAL;
if (u->manager->running_as == SYSTEMD_SYSTEM) {