diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-01-31 16:21:54 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-02-01 09:25:57 +0100 |
commit | 0e8330262e9fe081c80347a1b3badf649ed75857 (patch) | |
tree | 9a94990df9710158c890fbdd44e860adaef55589 | |
parent | 2308cf7c9c2f9b577a13ef6886ec1aa8f1cd21c2 (diff) | |
download | systemd-0e8330262e9fe081c80347a1b3badf649ed75857.tar.gz |
journald: some minor modernizations
-rw-r--r-- | src/journal/managed-journal-file.c | 35 | ||||
-rw-r--r-- | src/libsystemd/sd-journal/journal-file.c | 4 |
2 files changed, 29 insertions, 10 deletions
diff --git a/src/journal/managed-journal-file.c b/src/journal/managed-journal-file.c index 810167772a..81aecfe7cb 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 5e29878d47..a2111b6967 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); |