]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: shorten code a bit
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2024 11:07:22 +0000 (20:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 15 Feb 2024 00:50:18 +0000 (09:50 +0900)
src/libsystemd/sd-journal/journal-file.c

index 8039b2aaf95bb6703c8fa52ae338b28c210a7feb..3f694cfabf11bf9bf802cab75e867b2c67c34b93 100644 (file)
@@ -4358,11 +4358,9 @@ int journal_file_archive(JournalFile *f, char **ret_previous_path) {
         (void) fsync_directory_of_file(f->fd);
 
         if (ret_previous_path)
-                *ret_previous_path = f->path;
-        else
-                free(f->path);
+                *ret_previous_path = TAKE_PTR(f->path);
 
-        f->path = TAKE_PTR(p);
+        free_and_replace(f->path, p);
 
         /* Set as archive so offlining commits w/state=STATE_ARCHIVED. Previously we would set old_file->header->state
          * to STATE_ARCHIVED directly here, but journal_file_set_offline() short-circuits when state != STATE_ONLINE,