From: Francois-Xavier Bourlet Date: Sun, 21 Aug 2011 09:05:40 +0000 (+0200) Subject: fix xff excessive rounding X-Git-Tag: collectd-4.10.4~7^2 X-Git-Url: https://git.tokkee.org/?p=collectd.git;a=commitdiff_plain;h=ca86420e6801c5e97cc40176cce27d2b0125a430 fix xff excessive rounding Hi, When generating arguments for rrd_create, the previous format string "%.1f", was rounding up the value too aggressively. ex: for xff==0.9999 the result would be -> 1.0 (invalid value for xff!) The new format string is "%.10f", which lead up to 10 digits after the dot, enough to be close to the double type limit, and so handling correctly the previous example. Change-Id: I7c6cc55b0d43beb5ef351bb04b67f4628249c737 --- diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c index 66bb27e7..47bf9f66 100644 --- a/src/utils_rrdcreate.c +++ b/src/utils_rrdcreate.c @@ -153,7 +153,7 @@ static int rra_get (char ***ret, const value_list_t *vl, /* {{{ */ if (rra_num >= rra_max) break; - status = ssnprintf (buffer, sizeof (buffer), "RRA:%s:%3.1f:%u:%u", + status = ssnprintf (buffer, sizeof (buffer), "RRA:%s:%.10f:%u:%u", rra_types[j], cfg->xff, cdp_len, cdp_num); if ((status < 0) || ((size_t) status >= sizeof (buffer)))