From a30e35f85aa9917e59183cecfcbbee986d549b46 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 22 Nov 2019 15:22:24 +0100 Subject: [PATCH] journald: let's use unlink_and_free() where we can --- src/journal/journald-stream.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 22a70ce5a69..098ee96e79d 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -17,6 +17,7 @@ #include "escape.h" #include "fd-util.h" #include "fileio.h" +#include "fs-util.h" #include "io-util.h" #include "journald-console.h" #include "journald-context.h" @@ -139,7 +140,7 @@ void stdout_stream_destroy(StdoutStream *s) { } static int stdout_stream_save(StdoutStream *s) { - _cleanup_free_ char *temp_path = NULL; + _cleanup_(unlink_and_freep) char *temp_path = NULL; _cleanup_fclose_ FILE *f = NULL; int r; @@ -214,6 +215,8 @@ static int stdout_stream_save(StdoutStream *s) { goto fail; } + temp_path = mfree(temp_path); + if (!s->fdstore && !s->in_notify_queue) { LIST_PREPEND(stdout_stream_notify_queue, s->server->stdout_streams_notify_queue, s); s->in_notify_queue = true; @@ -229,10 +232,6 @@ static int stdout_stream_save(StdoutStream *s) { fail: (void) unlink(s->state_file); - - if (temp_path) - (void) unlink(temp_path); - return log_error_errno(r, "Failed to save stream data %s: %m", s->state_file); } -- 2.47.3