]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-file-util: drop unused template argument for journal_file_open_reliably()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2024 11:21:25 +0000 (20:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 15 Feb 2024 00:50:18 +0000 (09:50 +0900)
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.

src/journal-remote/journal-remote.c
src/journal/journald-server.c
src/shared/journal-file-util.c
src/shared/journal-file-util.h

index 7c5ccbbea6f0cf91717dfecfada33a2d38d013aa..2d309d12362ae02b1eb0fbeb5c6f807d9c0896aa 100644 (file)
@@ -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);
index 13e8895d059de15443aa41f76f20a3517ec904b4..da73b668b61ae01252258dac1296ed1cd21336b2 100644 (file)
@@ -289,7 +289,6 @@ static int server_open_journal(
                                 s->compress.threshold_bytes,
                                 metrics,
                                 s->mmap,
-                                /* template= */ NULL,
                                 &f);
         else
                 r = journal_file_open(
index d34dbe030e3e9394ac82b0707fd36f2ff2664dcf..f013836a370ff15027bb5a6f53e38f886a63d579 100644 (file)
@@ -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);
 }
index f9426c47d7447e2b1721a1afbf8b9908a54e3952..8df10a79271be17ded5e3690a8e636609a30fa9d 100644 (file)
@@ -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);