Code

fix error messages on the road to fix #222
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Fri, 22 May 2009 11:32:21 +0000 (11:32 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Fri, 22 May 2009 11:32:21 +0000 (11:32 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3/program@1804 a5681a0c-68f1-0310-ab6d-d61299d08faa

src/rrd_update.c

index 1ae36f9cc32241d03a9cdc08dccfe48dd010107b..1716a5b184d16b32ec0aff7d8ab28e47694760b7 100644 (file)
@@ -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'",