summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-11 13:22:13 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-20 18:49:14 -0500
commitcb4499d0056a7c974d7d3695cc355c7e77edc938 (patch)
treeb77b92c9feaa7a156b80866b8a6fd02d9ebf1865 /src
parent79d615d56c186475089bc617f6d6850d89687e38 (diff)
basic/env-util: use _cleanup_ in replace_env()
Diffstat (limited to 'src')
-rw-r--r--src/basic/env-util.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c
index 99a130008b..8774a81531 100644
--- a/src/basic/env-util.c
+++ b/src/basic/env-util.c
@@ -527,7 +527,8 @@ char *replace_env(const char *format, char **env, unsigned flags) {
} state = WORD;
const char *e, *word = format;
- char *r = NULL, *k;
+ char *k;
+ _cleanup_free_ char *r = NULL;
assert(format);
@@ -544,7 +545,7 @@ char *replace_env(const char *format, char **env, unsigned flags) {
if (*e == '{') {
k = strnappend(r, word, e-word-1);
if (!k)
- goto fail;
+ return NULL;
free(r);
r = k;
@@ -555,7 +556,7 @@ char *replace_env(const char *format, char **env, unsigned flags) {
} else if (*e == '$') {
k = strnappend(r, word, e-word);
if (!k)
- goto fail;
+ return NULL;
free(r);
r = k;
@@ -574,7 +575,7 @@ char *replace_env(const char *format, char **env, unsigned flags) {
k = strappend(r, t);
if (!k)
- goto fail;
+ return NULL;
free(r);
r = k;
@@ -586,15 +587,7 @@ char *replace_env(const char *format, char **env, unsigned flags) {
}
}
- k = strnappend(r, word, e-word);
- if (!k)
- goto fail;
-
- free(r);
- return k;
-
-fail:
- return mfree(r);
+ return strnappend(r, word, e-word);
}
char **replace_env_argv(char **argv, char **env) {