From: Yu Watanabe Date: Fri, 9 Feb 2024 11:21:25 +0000 (+0900) Subject: journal-file-util: drop unused template argument for journal_file_open_reliably() X-Git-Tag: v256-rc1~853^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da96afcd6c7e3f5aec370ae35e532b913ac5ea41;p=thirdparty%2Fsystemd.git journal-file-util: drop unused template argument for journal_file_open_reliably() I understand that the original motivation to introduce the template argument here is to make journal_file_open() and _reliabrly() take the same arguments. But, yeah, that's completely unused, not necessary to complicate the code even the difference is not big. --- diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 7c5ccbbea6f..2d309d12362 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -86,7 +86,6 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) { UINT64_MAX, &w->metrics, w->mmap, - NULL, &w->journal); if (r < 0) return log_error_errno(r, "Failed to open output journal %s: %m", filename); diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 13e8895d059..da73b668b61 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -289,7 +289,6 @@ static int server_open_journal( s->compress.threshold_bytes, metrics, s->mmap, - /* template= */ NULL, &f); else r = journal_file_open( diff --git a/src/shared/journal-file-util.c b/src/shared/journal-file-util.c index d34dbe030e3..f013836a370 100644 --- a/src/shared/journal-file-util.c +++ b/src/shared/journal-file-util.c @@ -471,7 +471,6 @@ int journal_file_open_reliably( uint64_t compress_threshold_bytes, JournalMetrics *metrics, MMapCache *mmap_cache, - JournalFile *template, JournalFile **ret) { _cleanup_(journal_file_offline_closep) JournalFile *old_file = NULL; @@ -486,7 +485,7 @@ int journal_file_open_reliably( compress_threshold_bytes, metrics, mmap_cache, - template, + /* template = */ NULL, ret); if (!IN_SET(r, -EBADMSG, /* Corrupted */ @@ -512,23 +511,19 @@ int journal_file_open_reliably( /* The file is corrupted. Rotate it away and try it again (but only once) */ log_warning_errno(r, "File %s corrupted or uncleanly shut down, renaming and replacing.", fname); - if (!template) { - /* The file is corrupted and no template is specified. Try opening it read-only as the - * template before rotating to inherit its sequence number and ID. */ - r = journal_file_open(-EBADF, fname, - (open_flags & ~(O_ACCMODE|O_CREAT|O_EXCL)) | O_RDONLY, - file_flags, 0, compress_threshold_bytes, NULL, - mmap_cache, NULL, &old_file); - if (r < 0) - log_debug_errno(r, "Failed to continue sequence from file %s, ignoring: %m", fname); - else - template = old_file; - } + /* The file is corrupted. Try opening it read-only as the template before rotating to inherit its + * sequence number and ID. */ + r = journal_file_open(-EBADF, fname, + (open_flags & ~(O_ACCMODE|O_CREAT|O_EXCL)) | O_RDONLY, + file_flags, 0, compress_threshold_bytes, NULL, + mmap_cache, /* template = */ NULL, &old_file); + if (r < 0) + log_debug_errno(r, "Failed to continue sequence from file %s, ignoring: %m", fname); r = journal_file_dispose(AT_FDCWD, fname); if (r < 0) return r; return journal_file_open(-EBADF, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics, - mmap_cache, template, ret); + mmap_cache, /* template = */ old_file, ret); } diff --git a/src/shared/journal-file-util.h b/src/shared/journal-file-util.h index f9426c47d74..8df10a79271 100644 --- a/src/shared/journal-file-util.h +++ b/src/shared/journal-file-util.h @@ -17,7 +17,6 @@ int journal_file_open_reliably( uint64_t compress_threshold_bytes, JournalMetrics *metrics, MMapCache *mmap_cache, - JournalFile *template, JournalFile **ret); JournalFile* journal_file_initiate_close(JournalFile *f, Set *deferred_closes);