diff options
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/catalog.c | 12 | ||||
-rw-r--r-- | src/journal/journald-stream.c | 26 |
2 files changed, 17 insertions, 21 deletions
diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 0801e13599..33b0539315 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -371,25 +371,23 @@ static long write_catalog(const char *database, Hashmap *h, struct strbuf *sb, goto error; } - fflush(w); - - if (ferror(w)) { - log_error("%s: failed to write database.", p); + r = fflush_and_check(w); + if (r < 0) { + log_error_errno(r, "%s: failed to write database: %m", p); goto error; } fchmod(fileno(w), 0644); if (rename(p, database) < 0) { - log_error_errno(errno, "rename (%s -> %s) failed: %m", p, database); - r = -errno; + r = log_error_errno(errno, "rename (%s -> %s) failed: %m", p, database); goto error; } return ftell(w); error: - unlink(p); + (void) unlink(p); return r; } diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index db2f581972..69e2d41863 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -142,7 +142,7 @@ static int stdout_stream_save(StdoutStream *s) { r = fopen_temporary(s->state_file, &f, &temp_path); if (r < 0) - goto finish; + goto fail; fprintf(f, "# This is private data. Do not parse\n" @@ -163,7 +163,7 @@ static int stdout_stream_save(StdoutStream *s) { escaped = cescape(s->identifier); if (!escaped) { r = -ENOMEM; - goto finish; + goto fail; } fprintf(f, "IDENTIFIER=%s\n", escaped); @@ -175,7 +175,7 @@ static int stdout_stream_save(StdoutStream *s) { escaped = cescape(s->unit_id); if (!escaped) { r = -ENOMEM; - goto finish; + goto fail; } fprintf(f, "UNIT=%s\n", escaped); @@ -183,16 +183,13 @@ static int stdout_stream_save(StdoutStream *s) { r = fflush_and_check(f); if (r < 0) - goto finish; + goto fail; if (rename(temp_path, s->state_file) < 0) { r = -errno; - goto finish; + goto fail; } - free(temp_path); - temp_path = NULL; - /* Store the connection fd in PID 1, so that we get it passed * in again on next start */ if (!s->fdstore) { @@ -200,14 +197,15 @@ static int stdout_stream_save(StdoutStream *s) { s->fdstore = true; } -finish: - if (temp_path) - unlink(temp_path); + return 0; - if (r < 0) - log_error_errno(r, "Failed to save stream data %s: %m", s->state_file); +fail: + (void) unlink(s->state_file); + + if (temp_path) + (void) unlink(temp_path); - return r; + return log_error_errno(r, "Failed to save stream data %s: %m", s->state_file); } static int stdout_stream_log(StdoutStream *s, const char *p) { |