]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: boot_id is always non-NULL
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Sep 2023 17:42:31 +0000 (02:42 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Sep 2023 04:26:22 +0000 (13:26 +0900)
The two callers of journal_file_append_entry_internal() always pass
non-NULL boot ID.

src/libsystemd/sd-journal/journal-file.c

index 638a6e1f9d619b00e470d978e188b81da417c62c..872f16b386c45d2cac13f597f1eb6e43ea883964 100644 (file)
@@ -2298,6 +2298,7 @@ static int journal_file_append_entry_internal(
         assert(f);
         assert(f->header);
         assert(ts);
+        assert(boot_id);
         assert(items || n_items == 0);
 
         if (f->strict_order) {
@@ -2318,7 +2319,7 @@ static int journal_file_append_entry_internal(
                                                "timestamp %" PRIu64 ", refusing entry.",
                                                ts->realtime, le64toh(f->header->tail_entry_realtime));
 
-                if ((!boot_id || sd_id128_equal(*boot_id, f->header->tail_entry_boot_id)) &&
+                if (sd_id128_equal(*boot_id, f->header->tail_entry_boot_id) &&
                     ts->monotonic < le64toh(f->header->tail_entry_monotonic))
                         return log_debug_errno(
                                         SYNTHETIC_ERRNO(ENOTNAM),
@@ -2358,9 +2359,7 @@ static int journal_file_append_entry_internal(
         o->entry.realtime = htole64(ts->realtime);
         o->entry.monotonic = htole64(ts->monotonic);
         o->entry.xor_hash = htole64(xor_hash);
-        if (boot_id)
-                f->header->tail_entry_boot_id = *boot_id;
-        o->entry.boot_id = f->header->tail_entry_boot_id;
+        o->entry.boot_id = f->header->tail_entry_boot_id = *boot_id;
 
         for (size_t i = 0; i < n_items; i++)
                 write_entry_item(f, o, i, &items[i]);