From 848678e4d5cf340785ec15fee7f3b87c7ce475b9 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 19 Feb 2014 17:49:50 +0100
Subject: [PATCH] journal: don't clobber return parameters of
sd_journal_get_cutoff_realtime_usec() on failure
(cherry picked from commit 581483bf59ea62147739e71dd2216477be03411c)
(cherry picked from commit e19b6a48bfeddc3102b757df36f9da17c5215c5b)
---
src/journal/sd-journal.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 91e3cd8119..8ac6c05668 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2210,6 +2210,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;
if (!j)
@@ -2229,19 +2230,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;
}