From: Florian Forster Date: Fri, 21 Aug 2015 10:49:04 +0000 (+0200) Subject: src/daemon/utils_time.h: Don't cast input to time_t. X-Git-Tag: collectd-5.6.0~611 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0df29b436e77269eba38d66a2d43e99e5952a50a;p=collectd.git src/daemon/utils_time.h: Don't cast input to time_t. The CDTIME_T_TO_TIME_T() macro used to cast its input to time_t, which is a 32bit type on (some?) 32bit architectures. This is a regression introduced in db1391aaa66b8b8fad82219494f61f3452441f62 and not found in any released version of collectd. Phew! --- diff --git a/src/daemon/utils_time.h b/src/daemon/utils_time.h index 6476780a..2cc84b5d 100644 --- a/src/daemon/utils_time.h +++ b/src/daemon/utils_time.h @@ -1,6 +1,6 @@ /** - * collectd - src/utils_time.h - * Copyright (C) 2010 Florian octo Forster + * collectd - src/daemon/utils_time.h + * Copyright (C) 2010-2015 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,7 @@ * DEALINGS IN THE SOFTWARE. * * Authors: - * Florian octo Forster + * Florian octo Forster **/ #ifndef UTILS_TIME_H @@ -51,13 +51,13 @@ #define NS_TO_CDTIME_T(ns) (((((cdtime_t) (ns)) / 1000000000) << 30) | \ ((((((cdtime_t) (ns)) % 1000000000) << 30) + 500000000) / 1000000000)) -#define CDTIME_T_TO_TIME_T(t) ((((time_t) (t)) + (1 << 29)) >> 30) -#define CDTIME_T_TO_MS(t) (((((uint64_t) (t)) >> 30) * 1000L) + \ - (((((uint64_t) (t)) & 0x3fffffff) * 1000L + (1 << 29)) >> 30)) -#define CDTIME_T_TO_US(t) (((((uint64_t) (t)) >> 30) * 1000000L) + \ - (((((uint64_t) (t)) & 0x3fffffff) * 1000000L + (1 << 29)) >> 30)) -#define CDTIME_T_TO_NS(t) (((((uint64_t) (t)) >> 30) * 1000000000L) + \ - (((((uint64_t) (t)) & 0x3fffffff) * 1000000000L + (1 << 29)) >> 30)) +#define CDTIME_T_TO_TIME_T(t) ((time_t) (((t) + (1 << 29)) >> 30)) +#define CDTIME_T_TO_MS(t) ((uint64_t) ((((t) >> 30) * 1000) + \ + ((((t) & 0x3fffffff) * 1000 + (1 << 29)) >> 30))) +#define CDTIME_T_TO_US(t) ((uint64_t) ((((t) >> 30) * 1000000) + \ + ((((t) & 0x3fffffff) * 1000000 + (1 << 29)) >> 30))) +#define CDTIME_T_TO_NS(t) ((uint64_t) ((((t) >> 30) * 1000000000) + \ + ((((t) & 0x3fffffff) * 1000000000 + (1 << 29)) >> 30))) #define CDTIME_T_TO_DOUBLE(t) (((double) (t)) / 1073741824.0) #define DOUBLE_TO_CDTIME_T(d) ((cdtime_t) ((d) * 1073741824.0))