From: Lennart Poettering Date: Tue, 31 Jan 2023 15:21:54 +0000 (+0100) Subject: journald: some minor modernizations X-Git-Tag: v253-rc2~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e8330262e9fe081c80347a1b3badf649ed75857;p=thirdparty%2Fsystemd.git journald: some minor modernizations --- diff --git a/src/journal/managed-journal-file.c b/src/journal/managed-journal-file.c index 810167772ad..81aecfe7cb9 100644 --- a/src/journal/managed-journal-file.c +++ b/src/journal/managed-journal-file.c @@ -423,6 +423,7 @@ int managed_journal_file_open( Set *deferred_closes, ManagedJournalFile *template, ManagedJournalFile **ret) { + _cleanup_free_ ManagedJournalFile *f = NULL; int r; @@ -432,8 +433,17 @@ int managed_journal_file_open( if (!f) return -ENOMEM; - r = journal_file_open(fd, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics, - mmap_cache, template ? template->file : NULL, &f->file); + r = journal_file_open( + fd, + fname, + open_flags, + file_flags, + mode, + compress_threshold_bytes, + metrics, + mmap_cache, + template ? template->file : NULL, + &f->file); if (r < 0) return r; @@ -442,7 +452,6 @@ int managed_journal_file_open( return 0; } - ManagedJournalFile* managed_journal_file_initiate_close(ManagedJournalFile *f, Set *deferred_closes) { int r; @@ -480,16 +489,16 @@ int managed_journal_file_rotate( return r; r = managed_journal_file_open( - -1, + /* fd= */ -1, path, (*f)->file->open_flags, file_flags, (*f)->file->mode, compress_threshold_bytes, - NULL, /* metrics */ + /* metrics= */ NULL, mmap_cache, deferred_closes, - *f, /* template */ + /* template= */ *f, &new_file); managed_journal_file_initiate_close(*f, deferred_closes); @@ -513,8 +522,18 @@ int managed_journal_file_open_reliably( _cleanup_(managed_journal_file_closep) ManagedJournalFile *old_file = NULL; int r; - r = managed_journal_file_open(-1, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics, - mmap_cache, deferred_closes, template, ret); + r = managed_journal_file_open( + /* fd= */ -1, + fname, + open_flags, + file_flags, + mode, + compress_threshold_bytes, + metrics, + mmap_cache, + deferred_closes, + template, + ret); if (!IN_SET(r, -EBADMSG, /* Corrupted */ -ENODATA, /* Truncated */ diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 5e29878d479..a2111b69671 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -522,11 +522,11 @@ static int journal_file_verify_header(JournalFile *f) { if (state == STATE_ARCHIVED) return -ESHUTDOWN; /* Already archived */ - else if (state == STATE_ONLINE) + if (state == STATE_ONLINE) return log_debug_errno(SYNTHETIC_ERRNO(EBUSY), "Journal file %s is already online. Assuming unclean closing.", f->path); - else if (state != STATE_OFFLINE) + if (state != STATE_OFFLINE) return log_debug_errno(SYNTHETIC_ERRNO(EBUSY), "Journal file %s has unknown state %i.", f->path, state);