1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-08-31 09:50:11 +03:00

journal: as per coding style don't clobber return parameters in sd_journal_get_cutoff_monotonic_usec() on failure

This commit is contained in:
Lennart Poettering
2021-06-08 22:20:16 +02:00
parent 900952ecd5
commit f4cb1bfd57

View File

@ -2783,20 +2783,25 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
return first ? 0 : 1; return first ? 0 : 1;
} }
_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) { _public_ int sd_journal_get_cutoff_monotonic_usec(
JournalFile *f; sd_journal *j,
sd_id128_t boot_id,
uint64_t *ret_from,
uint64_t *ret_to) {
uint64_t from = UINT64_MAX, to = UINT64_MAX;
bool found = false; bool found = false;
JournalFile *f;
int r; int r;
assert_return(j, -EINVAL); assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD); assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(from || to, -EINVAL); assert_return(ret_from != ret_to, -EINVAL);
assert_return(from != to, -EINVAL);
ORDERED_HASHMAP_FOREACH(f, j->files) { ORDERED_HASHMAP_FOREACH(f, j->files) {
usec_t fr, t; usec_t ff, tt;
r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &fr, &t); r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &ff, &tt);
if (r == -ENOENT) if (r == -ENOENT)
continue; continue;
if (r < 0) if (r < 0)
@ -2805,19 +2810,20 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot
continue; continue;
if (found) { if (found) {
if (from) from = MIN(ff, from);
*from = MIN(fr, *from); to = MAX(tt, to);
if (to)
*to = MAX(t, *to);
} else { } else {
if (from) from = ff;
*from = fr; to = tt;
if (to)
*to = t;
found = true; found = true;
} }
} }
if (ret_from)
*ret_from = from;
if (ret_to)
*ret_to = to;
return found; return found;
} }