summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 437bd5a)
raw | patch | inline | side by side (parent: 437bd5a)
author | Florian Forster <octo@collectd.org> | |
Tue, 8 Dec 2015 09:33:17 +0000 (10:33 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 8 Dec 2015 09:33:17 +0000 (10:33 +0100) |
This change also partially expands CDTIME_T_TO_{US,NS} to avoid dead
code warnings in Coverity.
Fixes: #1446
CID: 37950, 37951, 37952, 37953, 37954, 41722
code warnings in Coverity.
Fixes: #1446
CID: 37950, 37951, 37952, 37953, 37954, 41722
src/daemon/utils_time.h | patch | blob | history |
index 9e98040694eb8b57822653e6fc1df5296646a314..46faa9ce44dbd89e8dcc85e7411fc259d6138c4d 100644 (file)
--- a/src/daemon/utils_time.h
+++ b/src/daemon/utils_time.h
#define CDTIME_T_TO_DOUBLE(t) (((double) (t)) / 1073741824.0)
#define DOUBLE_TO_CDTIME_T(d) ((cdtime_t) ((d) * 1073741824.0))
-#define CDTIME_T_TO_TIMEVAL(cdt,tvp) do { \
- (tvp)->tv_sec = CDTIME_T_TO_TIME_T (cdt); \
- (tvp)->tv_usec = (suseconds_t) CDTIME_T_TO_US ((cdt) & 0x3fffffff); \
+#define CDTIME_T_TO_TIMEVAL(cdt,tvp) do { \
+ (tvp)->tv_sec = (time_t) ((cdt) >> 30); \
+ (tvp)->tv_usec = (suseconds_t) ((((cdt) & 0x3fffffff) * 1000000 + (1 << 29)) >> 30); \
} while (0)
#define TIMEVAL_TO_CDTIME_T(tv) US_TO_CDTIME_T(1000000 * (tv)->tv_sec + (tv)->tv_usec)
-#define CDTIME_T_TO_TIMESPEC(cdt,tsp) do { \
- (tsp)->tv_sec = CDTIME_T_TO_TIME_T (cdt); \
- (tsp)->tv_nsec = (long) CDTIME_T_TO_NS ((cdt) & 0x3fffffff); \
+#define CDTIME_T_TO_TIMESPEC(cdt,tsp) do { \
+ (tsp)->tv_sec = (time_t) ((cdt) >> 30); \
+ (tsp)->tv_nsec = (long) ((((cdt) & 0x3fffffff) * 1000000000 + (1 << 29)) >> 30); \
} while (0)
#define TIMESPEC_TO_CDTIME_T(ts) NS_TO_CDTIME_T(1000000000ULL * (ts)->tv_sec + (ts)->tv_nsec)