summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0bb7347)
raw | patch | inline | side by side (parent: 0bb7347)
author | Florian Forster <octo@collectd.org> | |
Sun, 27 Nov 2016 13:58:42 +0000 (14:58 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 27 Nov 2016 15:58:01 +0000 (16:58 +0100) |
So GCC 4.6 doesn't crash.
src/daemon/utils_time.h | patch | blob | history | |
src/utils_latency_config.c | patch | blob | history | |
src/utils_latency_test.c | patch | blob | history |
index 2d83e0bbc5639620b8d69d47288a51d13ade4fad..db510afe7b6755ed760d21ebba4308decccd630c 100644 (file)
--- a/src/daemon/utils_time.h
+++ b/src/daemon/utils_time.h
#define CDTIME_T_TO_DOUBLE(t) \
(double) { ((double)(t)) / 1073741824.0 }
+#define DOUBLE_TO_CDTIME_T_STATIC(d) ((cdtime_t)((d)*1073741824.0))
#define DOUBLE_TO_CDTIME_T(d) \
- (cdtime_t) { (cdtime_t)((d)*1073741824.0) }
+ (cdtime_t) { DOUBLE_TO_CDTIME_T_STATIC(d) }
#define CDTIME_T_TO_TIMEVAL(t) \
(struct timeval) { \
index 36c78ebe9973fb858b8b4b68d5776e2f07ea8990..133678e56e873eb9af4f6eb683ef5d386bbc359f 100644 (file)
@@ -85,10 +85,10 @@ static int latency_config_add_bucket(latency_config_t *conf, oconfig_item_t *ci,
return ENOMEM;
}
conf->buckets = tmp;
- conf->buckets[conf->buckets_num] = (latency_bucket_t){
- .lower_bound = DOUBLE_TO_CDTIME_T(ci->values[0].value.number),
- .upper_bound = DOUBLE_TO_CDTIME_T(ci->values[1].value.number),
- };
+ conf->buckets[conf->buckets_num].lower_bound =
+ DOUBLE_TO_CDTIME_T(ci->values[0].value.number);
+ conf->buckets[conf->buckets_num].upper_bound =
+ DOUBLE_TO_CDTIME_T(ci->values[1].value.number);
conf->buckets_num++;
return (0);
index 3505ca3e22ee1aab055dcfb81be7fdc97a14a0c3..01f194f1cb9d4efbbe44b97179e32487b5cc3042 100644 (file)
--- a/src/utils_latency_test.c
+++ b/src/utils_latency_test.c
double want;
} cases[] = {
{ // bucket 6 is zero
- DOUBLE_TO_CDTIME_T(0.750),
- DOUBLE_TO_CDTIME_T(0.875),
+ DOUBLE_TO_CDTIME_T_STATIC(0.750),
+ DOUBLE_TO_CDTIME_T_STATIC(0.875),
0.00,
},
{ // bucket 7 contains the t=1 update
- DOUBLE_TO_CDTIME_T(0.875),
- DOUBLE_TO_CDTIME_T(1.000),
+ DOUBLE_TO_CDTIME_T_STATIC(0.875),
+ DOUBLE_TO_CDTIME_T_STATIC(1.000),
1.00,
},
{ // range: bucket 7 - bucket 15; contains the t=1 and t=2 updates
- DOUBLE_TO_CDTIME_T(0.875),
- DOUBLE_TO_CDTIME_T(2.000),
+ DOUBLE_TO_CDTIME_T_STATIC(0.875),
+ DOUBLE_TO_CDTIME_T_STATIC(2.000),
2.00,
},
{ // lower bucket is only partially applied
- DOUBLE_TO_CDTIME_T(0.875 + (0.125 / 4)),
- DOUBLE_TO_CDTIME_T(2.000),
+ DOUBLE_TO_CDTIME_T_STATIC(0.875 + (0.125 / 4)),
+ DOUBLE_TO_CDTIME_T_STATIC(2.000),
1.75,
},
{ // upper bucket is only partially applied
- DOUBLE_TO_CDTIME_T(0.875),
- DOUBLE_TO_CDTIME_T(2.000 - (0.125 / 4)),
+ DOUBLE_TO_CDTIME_T_STATIC(0.875),
+ DOUBLE_TO_CDTIME_T_STATIC(2.000 - (0.125 / 4)),
1.75,
},
{ // both buckets are only partially applied
- DOUBLE_TO_CDTIME_T(0.875 + (0.125 / 4)),
- DOUBLE_TO_CDTIME_T(2.000 - (0.125 / 4)),
+ DOUBLE_TO_CDTIME_T_STATIC(0.875 + (0.125 / 4)),
+ DOUBLE_TO_CDTIME_T_STATIC(2.000 - (0.125 / 4)),
1.50,
},
{ // lower bound is unspecified
0,
- DOUBLE_TO_CDTIME_T(2.000),
+ DOUBLE_TO_CDTIME_T_STATIC(2.000),
2.00,
},
{ // upper bound is unspecified
- DOUBLE_TO_CDTIME_T(125.000 - 0.125),
+ DOUBLE_TO_CDTIME_T_STATIC(125.000 - 0.125),
0,
1.00,
},
{ // overflow test: upper >> longest latency
- DOUBLE_TO_CDTIME_T(1.000),
- DOUBLE_TO_CDTIME_T(999999),
+ DOUBLE_TO_CDTIME_T_STATIC(1.000),
+ DOUBLE_TO_CDTIME_T_STATIC(999999),
124.00,
},
{ // overflow test: lower > longest latency
- DOUBLE_TO_CDTIME_T(130),
+ DOUBLE_TO_CDTIME_T_STATIC(130),
0,
0.00,
},
{ // lower > upper => error
- DOUBLE_TO_CDTIME_T(10),
- DOUBLE_TO_CDTIME_T(9),
+ DOUBLE_TO_CDTIME_T_STATIC(10),
+ DOUBLE_TO_CDTIME_T_STATIC(9),
NAN,
},
{ // lower == upper => zero
- DOUBLE_TO_CDTIME_T(9),
- DOUBLE_TO_CDTIME_T(9),
+ DOUBLE_TO_CDTIME_T_STATIC(9),
+ DOUBLE_TO_CDTIME_T_STATIC(9),
0.00,
},
};