Blame SOURCES/0319-journal-use-cleanup-attribute-at-one-more-place.patch

ddca0b
From ceacf935ac9f59bc08b5901f70f227958a2bcf52 Mon Sep 17 00:00:00 2001
ddca0b
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ddca0b
Date: Tue, 28 May 2019 18:07:01 +0900
ddca0b
Subject: [PATCH] journal: use cleanup attribute at one more place
ddca0b
ddca0b
(cherry picked from commit 627df1dc42b68a74b0882b06366d1185b1a34332)
ddca0b
ddca0b
Conflicts:
ddca0b
	src/journal/journald-server.c
ddca0b
ddca0b
Related: #1788085
ddca0b
---
ddca0b
 src/journal/journal-file.h    | 1 +
ddca0b
 src/journal/journald-server.c | 9 ++++-----
ddca0b
 2 files changed, 5 insertions(+), 5 deletions(-)
ddca0b
ddca0b
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
ddca0b
index cd8a48a364..6a44fd39d2 100644
ddca0b
--- a/src/journal/journal-file.h
ddca0b
+++ b/src/journal/journal-file.h
ddca0b
@@ -144,6 +144,7 @@ int journal_file_open(
ddca0b
 int journal_file_set_offline(JournalFile *f, bool wait);
ddca0b
 bool journal_file_is_offlining(JournalFile *f);
ddca0b
 JournalFile* journal_file_close(JournalFile *j);
ddca0b
+DEFINE_TRIVIAL_CLEANUP_FUNC(JournalFile*, journal_file_close);
ddca0b
 
ddca0b
 int journal_file_open_reliably(
ddca0b
                 const char *fname,
ddca0b
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
ddca0b
index 6250eab831..7632e2d9d0 100644
ddca0b
--- a/src/journal/journald-server.c
ddca0b
+++ b/src/journal/journald-server.c
ddca0b
@@ -253,8 +253,9 @@ static int open_journal(
ddca0b
                 bool seal,
ddca0b
                 JournalMetrics *metrics,
ddca0b
                 JournalFile **ret) {
ddca0b
+
ddca0b
+        _cleanup_(journal_file_closep) JournalFile *f = NULL;
ddca0b
         int r;
ddca0b
-        JournalFile *f;
ddca0b
 
ddca0b
         assert(s);
ddca0b
         assert(fname);
ddca0b
@@ -271,12 +272,10 @@ static int open_journal(
ddca0b
                 return r;
ddca0b
 
ddca0b
         r = journal_file_enable_post_change_timer(f, s->event, POST_CHANGE_TIMER_INTERVAL_USEC);
ddca0b
-        if (r < 0) {
ddca0b
-                (void) journal_file_close(f);
ddca0b
+        if (r < 0)
ddca0b
                 return r;
ddca0b
-        }
ddca0b
 
ddca0b
-        *ret = f;
ddca0b
+        *ret = TAKE_PTR(f);
ddca0b
         return r;
ddca0b
 }
ddca0b