summaryrefslogtreecommitdiff
path: root/src/journal/journald-stream.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-07-29 20:31:07 +0200
committerLennart Poettering <lennart@poettering.net>2015-07-29 20:31:07 +0200
commitdacd6cee76a08331b8c8616c5f30f70ee49aa2f9 (patch)
tree7a7d73f2ac1f909255361781ca923365b6c9b7c3 /src/journal/journald-stream.c
parent8388607b5851574e50a6e65db98135b793b08910 (diff)
tree-wide: port everything over to fflush_and_check()
Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
Diffstat (limited to 'src/journal/journald-stream.c')
-rw-r--r--src/journal/journald-stream.c26
1 files changed, 12 insertions, 14 deletions
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) {