From c50f7338f03eebaaca98d08baef6cee0465bf9d1 Mon Sep 17 00:00:00 2001 From: oetiker Date: Fri, 22 May 2009 11:32:21 +0000 Subject: [PATCH] fix error messages on the road to fix #222 git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1804 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_update.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/program/src/rrd_update.c b/program/src/rrd_update.c index 1ae36f9c..1716a5b1 100644 --- a/program/src/rrd_update.c +++ b/program/src/rrd_update.c @@ -943,7 +943,13 @@ static int get_time_from_reading( *current_time_usec = tmp_time.tv_usec; } else { old_locale = setlocale(LC_NUMERIC, "C"); + errno = 0; tmp = strtod(updvals[0], 0); + if (errno > 0) { + rrd_set_error("converting '%s' to float: %s", + updvals[0], rrd_strerror(errno)); + return -1; + }; setlocale(LC_NUMERIC, old_locale); *current_time = floor(tmp); *current_time_usec = (long) ((tmp - (double) *current_time) * 1e6f); @@ -1039,12 +1045,12 @@ static int update_pdp_prep( old_locale = setlocale(LC_NUMERIC, "C"); errno = 0; pdp_new[ds_idx] = strtod(updvals[ds_idx + 1], &endptr); - setlocale(LC_NUMERIC, old_locale); if (errno > 0) { rrd_set_error("converting '%s' to float: %s", updvals[ds_idx + 1], rrd_strerror(errno)); return -1; }; + setlocale(LC_NUMERIC, old_locale); if (endptr[0] != '\0') { rrd_set_error ("conversion of '%s' to float not complete: tail '%s'", @@ -1058,12 +1064,12 @@ static int update_pdp_prep( old_locale = setlocale(LC_NUMERIC, "C"); pdp_new[ds_idx] = strtod(updvals[ds_idx + 1], &endptr) * interval; - setlocale(LC_NUMERIC, old_locale); if (errno) { rrd_set_error("converting '%s' to float: %s", updvals[ds_idx + 1], rrd_strerror(errno)); return -1; }; + setlocale(LC_NUMERIC, old_locale); if (endptr[0] != '\0') { rrd_set_error ("conversion of '%s' to float not complete: tail '%s'", -- 2.30.2