From 52035ebe0e7c8e2139832191eb03736134cd8a50 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/trunk/program@1804 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_update.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rrd_update.c b/src/rrd_update.c index 02e0b1a..bb242b7 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -964,7 +964,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); @@ -1060,12 +1066,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'", @@ -1079,12 +1085,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