diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-21 21:22:55 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-02-21 21:22:55 +0100 |
commit | c7044f9ed295ca2d83bcd0059a86a9443361eaec (patch) | |
tree | 4a16b1d792d13da8b7bd27045c12f7fcd29b816c /src/basic | |
parent | 714c62b46379abb7558c544665522aca91691e10 (diff) | |
parent | fdd21be6f5f0360c4627bcf5a7957e69ad08be74 (diff) |
Merge pull request #2681 from keszybz/udev-rules
udev-rules cleanup and coverity warning silencing
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/time-util.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 130acaa9de..9bfd8f4f7a 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -139,8 +139,7 @@ dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, us usec_t timespec_load(const struct timespec *ts) { assert(ts); - if (ts->tv_sec == (time_t) -1 && - ts->tv_nsec == (long) -1) + if (ts->tv_sec == (time_t) -1 && ts->tv_nsec == (long) -1) return USEC_INFINITY; if ((usec_t) ts->tv_sec > (UINT64_MAX - (ts->tv_nsec / NSEC_PER_USEC)) / USEC_PER_SEC) @@ -154,13 +153,13 @@ usec_t timespec_load(const struct timespec *ts) { static nsec_t timespec_load_nsec(const struct timespec *ts) { assert(ts); - if (ts->tv_sec == (time_t) -1 && - ts->tv_nsec == (long) -1) + if (ts->tv_sec == (time_t) -1 && ts->tv_nsec == (long) -1) return NSEC_INFINITY; - return - (nsec_t) ts->tv_sec * NSEC_PER_SEC + - (nsec_t) ts->tv_nsec; + if ((nsec_t) ts->tv_sec >= (UINT64_MAX - ts->tv_nsec) / NSEC_PER_SEC) + return NSEC_INFINITY; + + return (nsec_t) ts->tv_sec * NSEC_PER_SEC + (nsec_t) ts->tv_nsec; } struct timespec *timespec_store(struct timespec *ts, usec_t u) { |