diff options
Diffstat (limited to 'src/basic/rlimit-util.c')
-rw-r--r-- | src/basic/rlimit-util.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c index 23d108d5df..1ab41c6974 100644 --- a/src/basic/rlimit-util.c +++ b/src/basic/rlimit-util.c @@ -300,26 +300,26 @@ int rlimit_parse(int resource, const char *val, struct rlimit *ret) { } int rlimit_format(const struct rlimit *rl, char **ret) { - char *s = NULL; + _cleanup_free_ char *s = NULL; + int r; assert(rl); assert(ret); if (rl->rlim_cur >= RLIM_INFINITY && rl->rlim_max >= RLIM_INFINITY) - s = strdup("infinity"); + r = free_and_strdup(&s, "infinity"); else if (rl->rlim_cur >= RLIM_INFINITY) - (void) asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max); + r = asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max); else if (rl->rlim_max >= RLIM_INFINITY) - (void) asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur); + r = asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur); else if (rl->rlim_cur == rl->rlim_max) - (void) asprintf(&s, RLIM_FMT, rl->rlim_cur); + r = asprintf(&s, RLIM_FMT, rl->rlim_cur); else - (void) asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max); - - if (!s) + r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max); + if (r < 0) return -ENOMEM; - *ret = s; + *ret = TAKE_PTR(s); return 0; } |