diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index aa26902a20..32c6418482 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -268,8 +268,8 @@ static int gather_environment_generate(int fd, void *arg) { } static int gather_environment_collect(int fd, void *arg) { - char ***env = arg; _cleanup_fclose_ FILE *f = NULL; + char ***env = arg; int r; /* Write out a series of env=cescape(VAR=value) assignments to fd. */ @@ -286,8 +286,9 @@ static int gather_environment_collect(int fd, void *arg) { if (r < 0) return r; - if (ferror(f)) - return errno > 0 ? -errno : -EIO; + r = fflush_and_check(f); + if (r < 0) + return r; return 0; } diff --git a/src/core/service.c b/src/core/service.c index 29a70d1eea..660536837e 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2612,10 +2612,10 @@ static int service_deserialize_exec_command(Unit *u, const char *key, const char _cleanup_free_ char *arg = NULL; r = extract_first_word(&value, &arg, NULL, EXTRACT_CUNESCAPE); + if (r < 0) + return r; if (r == 0) break; - else if (r < 0) - return r; switch (state) { case STATE_EXEC_COMMAND_TYPE: @@ -2755,10 +2755,8 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, r = cunescape(value, 0, &t); if (r < 0) log_unit_debug_errno(u, r, "Failed to unescape status text: %s", value); - else { - free(s->status_text); - s->status_text = t; - } + else + free_and_replace(s->status_text, t); } else if (streq(key, "accept-socket")) { Unit *socket;