diff options
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-file.c | 23 | ||||
-rw-r--r-- | src/journal/sd-journal.c | 30 |
2 files changed, 25 insertions, 28 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 0587c432c1..3b19d3c444 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -2616,6 +2616,8 @@ void journal_file_save_location(JournalFile *f, Object *o, uint64_t offset) { } int journal_file_compare_locations(JournalFile *af, JournalFile *bf) { + int r; + assert(af); assert(af->header); assert(bf); @@ -2635,10 +2637,9 @@ int journal_file_compare_locations(JournalFile *af, JournalFile *bf) { /* If this is from the same seqnum source, compare * seqnums */ - if (af->current_seqnum < bf->current_seqnum) - return -1; - if (af->current_seqnum > bf->current_seqnum) - return 1; + r = CMP(af->current_seqnum, bf->current_seqnum); + if (r != 0) + return r; /* Wow! This is weird, different data but the same * seqnums? Something is borked, but let's make the @@ -2648,17 +2649,15 @@ int journal_file_compare_locations(JournalFile *af, JournalFile *bf) { if (sd_id128_equal(af->current_boot_id, bf->current_boot_id)) { /* If the boot id matches, compare monotonic time */ - if (af->current_monotonic < bf->current_monotonic) - return -1; - if (af->current_monotonic > bf->current_monotonic) - return 1; + r = CMP(af->current_monotonic, bf->current_monotonic); + if (r != 0) + return r; } /* Otherwise, compare UTC time */ - if (af->current_realtime < bf->current_realtime) - return -1; - if (af->current_realtime > bf->current_realtime) - return 1; + r = CMP(af->current_realtime, bf->current_realtime); + if (r != 0) + return r; /* Finally, compare by contents */ return CMP(af->current_xor_hash, bf->current_xor_hash); diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 83abd82d1c..023395d8de 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -433,6 +433,8 @@ _public_ void sd_journal_flush_matches(sd_journal *j) { } _pure_ static int compare_with_location(JournalFile *f, Location *l) { + int r; + assert(f); assert(l); assert(f->location_type == LOCATION_SEEK); @@ -449,35 +451,31 @@ _pure_ static int compare_with_location(JournalFile *f, Location *l) { if (l->seqnum_set && sd_id128_equal(f->header->seqnum_id, l->seqnum_id)) { - if (f->current_seqnum < l->seqnum) - return -1; - if (f->current_seqnum > l->seqnum) - return 1; + r = CMP(f->current_seqnum, l->seqnum); + if (r != 0) + return r; } if (l->monotonic_set && sd_id128_equal(f->current_boot_id, l->boot_id)) { - if (f->current_monotonic < l->monotonic) - return -1; - if (f->current_monotonic > l->monotonic) - return 1; + r = CMP(f->current_monotonic, l->monotonic); + if (r != 0) + return r; } if (l->realtime_set) { - if (f->current_realtime < l->realtime) - return -1; - if (f->current_realtime > l->realtime) - return 1; + r = CMP(f->current_realtime, l->realtime); + if (r != 0) + return r; } if (l->xor_hash_set) { - if (f->current_xor_hash < l->xor_hash) - return -1; - if (f->current_xor_hash > l->xor_hash) - return 1; + r = CMP(f->current_xor_hash, l->xor_hash); + if (r != 0) + return r; } return 0; |