diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-10-16 17:55:30 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-16 19:55:38 +0200 |
commit | 90c88092e66a1f915655f775d180301057781240 (patch) | |
tree | c5018e81c29e6666d6ae827bc7bfdc3701e10f84 /src/journal | |
parent | hwdb: add Aiptek Hyperpen 12000U (#10424) (diff) | |
download | systemd-90c88092e66a1f915655f775d180301057781240.tar.xz systemd-90c88092e66a1f915655f775d180301057781240.zip |
tree-wide: use CMP() macro where applicable
Follow-up for 6dd91b368298e3b3b264a5f2cb5647b2c5cb692b.
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; |