summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-19 17:49:50 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-19 17:53:50 +0100
commit581483bf59ea62147739e71dd2216477be03411c (patch)
treebaad943e9819bc618bce9bedc625692d768e11ed
parent1756a0118ea1ab25fd46c853e89853c7e4b3038c (diff)
downloadsystemd-581483bf59ea62147739e71dd2216477be03411c.tar.gz
journal: don't clobber return parameters of sd_journal_get_cutoff_realtime_usec() on failure
-rw-r--r--src/journal/sd-journal.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index fa2009c5dc..831ab6b4e9 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2347,6 +2347,7 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
Iterator i;
JournalFile *f;
bool first = true;
+ uint64_t fmin = 0, tmax = 0;
int r;
assert_return(j, -EINVAL);
@@ -2366,19 +2367,20 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
continue;
if (first) {
- if (from)
- *from = fr;
- if (to)
- *to = t;
+ fmin = fr;
+ tmax = t;
first = false;
} else {
- if (from)
- *from = MIN(fr, *from);
- if (to)
- *to = MAX(t, *to);
+ fmin = MIN(fr, fmin);
+ tmax = MAX(t, tmax);
}
}
+ if (from)
+ *from = fmin;
+ if (to)
+ *to = tmax;
+
return first ? 0 : 1;
}