diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2015-10-24 20:55:56 +0000 |
---|---|---|
committer | Evgeny Vereshchagin <evvers@ya.ru> | 2015-10-24 21:16:02 +0000 |
commit | 115cbf7e209a86cf5317fa12d44566247b4af332 (patch) | |
tree | d25a69defaff87f2f8aff38e709a8faf0d86c23c | |
parent | 7f66eb931d20cfdb7e1123673f2d6d08c2589bdf (diff) |
core: various small fixes to unit-printf
* check memory allocation errors in specifier_cgroup_slice
* %I doesn't fail for non-instantiated units (%i doesn't fail too)
* EOPNOTSUPP for consistency
-rw-r--r-- | src/core/unit-printf.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index 0889769d03..f327953266 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -63,10 +63,7 @@ static int specifier_instance_unescaped(char specifier, void *data, void *userda assert(u); - if (!u->instance) - return -EINVAL; - - return unit_name_unescape(u->instance, ret); + return unit_name_unescape(strempty(u->instance), ret); } static int specifier_filename(char specifier, void *data, void *userdata, char **ret) { @@ -128,6 +125,8 @@ static int specifier_cgroup_slice(char specifier, void *data, void *userdata, ch n = unit_default_cgroup_path(slice); } else n = strdup(u->manager->cgroup_root); + if (!n) + return -ENOMEM; *ret = n; return 0; @@ -166,7 +165,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char c = unit_get_exec_context(u); if (!c) - return -EINVAL; + return -EOPNOTSUPP; if (u->manager->running_as == MANAGER_SYSTEM) { |