From f916819053ff78a215d591a8cf5a873fafeb84f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 28 Nov 2017 12:40:14 +0100 Subject: [PATCH] journal: use new helpers with journal_file_close journal_file_close_set() is not necessary anymore. --- src/journal/journal-file.c | 12 +----------- src/journal/journal-file.h | 1 - src/journal/journald-server.c | 11 ++--------- src/journal/sd-journal.c | 6 +----- 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index faa7e9b..9d2e6db 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -400,15 +400,6 @@ JournalFile* journal_file_close(JournalFile *f) { return mfree(f); } -void journal_file_close_set(Set *s) { - JournalFile *f; - - assert(s); - - while ((f = set_steal_first(s))) - (void) journal_file_close(f); -} - static int journal_file_init_header(JournalFile *f, JournalFile *template) { Header h = {}; ssize_t k; @@ -3371,8 +3362,7 @@ int journal_file_open( f->header = h; if (!newly_created) { - if (deferred_closes) - journal_file_close_set(deferred_closes); + set_clear_with_destructor(deferred_closes, journal_file_close); r = journal_file_verify_header(f); if (r < 0) diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h index c652687..c5cfa3d 100644 --- a/src/journal/journal-file.h +++ b/src/journal/journal-file.h @@ -161,7 +161,6 @@ int journal_file_open( int journal_file_set_offline(JournalFile *f, bool wait); bool journal_file_is_offlining(JournalFile *f); JournalFile* journal_file_close(JournalFile *j); -void journal_file_close_set(Set *s); int journal_file_open_reliably( const char *fname, diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 8a2ad13..19ae529 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1899,13 +1899,9 @@ void server_maybe_append_tags(Server *s) { } void server_done(Server *s) { - JournalFile *f; assert(s); - if (s->deferred_closes) { - journal_file_close_set(s->deferred_closes); - set_free(s->deferred_closes); - } + set_free_with_destructor(s->deferred_closes, journal_file_close); while (s->stdout_streams) stdout_stream_free(s->stdout_streams); @@ -1918,10 +1914,7 @@ void server_done(Server *s) { if (s->runtime_journal) (void) journal_file_close(s->runtime_journal); - while ((f = ordered_hashmap_steal_first(s->user_journals))) - (void) journal_file_close(f); - - ordered_hashmap_free(s->user_journals); + ordered_hashmap_free_with_destructor(s->user_journals, journal_file_close); sd_event_source_unref(s->syslog_event_source); sd_event_source_unref(s->native_event_source); diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 59ddc73..8a1b161 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1977,17 +1977,13 @@ fail: _public_ void sd_journal_close(sd_journal *j) { Directory *d; - JournalFile *f; if (!j) return; sd_journal_flush_matches(j); - while ((f = ordered_hashmap_steal_first(j->files))) - (void) journal_file_close(f); - - ordered_hashmap_free(j->files); + ordered_hashmap_free_with_destructor(j->files, journal_file_close); while ((d = hashmap_first(j->directories_by_path))) remove_directory(j, d); -- 2.7.4