Merge pull request #10440 from poettering/fflush-and-check-some-more

use fflush_and_check() and free_and_replace() where we can
This commit is contained in:
Lennart Poettering 2018-10-17 22:54:34 +02:00 committed by GitHub
commit 67f5d31b45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -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;
}

View file

@ -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;