summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2016-02-10 13:39:48 +0100
committerDaniel Mack <github@zonque.org>2016-02-10 13:39:48 +0100
commit978d6650863f02942a4a180cacfc9d28f310d930 (patch)
treea10da7e0d190edb8d8671907c6c13fa8a7f3c7c9 /src/basic
parent42caedb2aae782659413f0f50ab824d58065c190 (diff)
parent04a1d84cefe4dbb5bfee86190489c3c07a8c238c (diff)
Merge pull request #2564 from poettering/fix-2467
Fix for #2467
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/time-util.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/basic/time-util.h b/src/basic/time-util.h
index 5b4b5b9485..4b4b2a2f5e 100644
--- a/src/basic/time-util.h
+++ b/src/basic/time-util.h
@@ -141,11 +141,13 @@ static inline usec_t usec_add(usec_t a, usec_t b) {
static inline usec_t usec_sub(usec_t timestamp, int64_t delta) {
if (delta < 0)
- timestamp = usec_add(timestamp, (usec_t) (-delta));
- else if (timestamp > (usec_t) delta)
- timestamp -= delta;
- else
- timestamp = 0;
+ return usec_add(timestamp, (usec_t) (-delta));
- return timestamp;
+ if (timestamp == USEC_INFINITY) /* Make sure infinity doesn't degrade */
+ return USEC_INFINITY;
+
+ if (timestamp < (usec_t) delta)
+ return 0;
+
+ return timestamp - delta;
}