From: Tobias Oetiker Date: Fri, 15 May 2015 03:18:07 +0000 (-0400) Subject: declare temp double at the start of the function X-Git-Tag: v1.5.4~39^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b55f7b395eb28601adea9437a3e3a4518654a3c9;p=thirdparty%2Frrdtool-1.x.git declare temp double at the start of the function --- diff --git a/src/rrd_create.c b/src/rrd_create.c index 223c63ef..04033fb7 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -456,7 +456,8 @@ int parseRRA(const char *def, int cf_id = -1; int token_min = 4; const char *parsetime_error = NULL; - + double tmpdbl; + memset(rra_def, 0, sizeof(rra_def_t)); argvcopy = strdup(def); @@ -531,13 +532,12 @@ int parseRRA(const char *def, rrd_set_error("Invalid row count %s: %s", token, parsetime_error); break; default: - double xff; - if (rrd_strtodbl(token, NULL, &xff, NULL) != 2 - || xff < 0.0 || xff >= 1.0 ){ + if (rrd_strtodbl(token, NULL, &tmpdbl, NULL) != 2 + || tmpdbl < 0.0 || tmpdbl >= 1.0 ){ rrd_set_error ("Invalid xff: must be between 0 and 1"); } - rra_def->par[RRA_cdp_xff_val].u_val = xff; + rra_def->par[RRA_cdp_xff_val].u_val = tmpdbl; break; } break; @@ -546,23 +546,21 @@ int parseRRA(const char *def, (rra_def->cf_nam)) { case CF_HWPREDICT: case CF_MHWPREDICT: - double hw_alpha; - if (rrd_strtodbl(token, NULL, &hw_alpha, NULL) != 2 - || hw_alpha <= 0.0 || hw_alpha >= 1.0){ + if (rrd_strtodbl(token, NULL, &tmpdbl, NULL) != 2 + || tmpdbl <= 0.0 || tmpdbl >= 1.0){ rrd_set_error ("Invalid alpha: must be between 0 and 1"); } - rra_def->par[RRA_hw_alpha].u_val = hw_alpha; + rra_def->par[RRA_hw_alpha].u_val = tmpdbl; break; case CF_DEVSEASONAL: case CF_SEASONAL: - double gamma; - if (rrd_strtodbl(token, NULL, &gamma, NULL) != 2 - || gamma <= 0.0 || gamma >= 1.0){ + if (rrd_strtodbl(token, NULL, &tmpdbl, NULL) != 2 + || tmpdbl <= 0.0 || tmpdbl >= 1.0){ rrd_set_error ("Invalid gamma: must be between 0 and 1"); } - rra_def->par[RRA_seasonal_gamma].u_val = gamma; + rra_def->par[RRA_seasonal_gamma].u_val = tmpdbl; rra_def->par[RRA_seasonal_smooth_idx].u_cnt = hash % rra_def->row_cnt; break; @@ -591,13 +589,12 @@ int parseRRA(const char *def, switch (cf_conv(rra_def->cf_nam)) { case CF_HWPREDICT: case CF_MHWPREDICT: - double beta; - if (rrd_strtodbl(token, NULL, &beta, NULL) != 2 - || beta < 0.0 || beta > 1.0){ + if (rrd_strtodbl(token, NULL, &tmpdbl, NULL) != 2 + || tmpdbl < 0.0 || tmpdbl > 1.0){ rrd_set_error ("Invalid beta: must be between 0 and 1"); } - rra_def->par[RRA_hw_beta].u_val = beta; + rra_def->par[RRA_hw_beta].u_val = tmpdbl; break; case CF_DEVSEASONAL: case CF_SEASONAL: