- case DST_COUNTER:
- case DST_DERIVE:
- for (ii = 0; updvals[ds_idx + 1][ii] != '\0'; ii++) {
- if ((updvals[ds_idx + 1][ii] < '0' || updvals[ds_idx + 1][ii] > '9')
- && (ii != 0 && updvals[ds_idx + 1][ii] != '-')) {
- rrd_set_error("not a simple integer: '%s'", updvals[ds_idx + 1]);
- return -1;
- }
- }
- if (rrd->pdp_prep[ds_idx].last_ds[0] != 'U') {
- pdp_new[ds_idx] = rrd_diff(updvals[ds_idx+1], rrd->pdp_prep[ds_idx].last_ds);
- if (dst_idx == DST_COUNTER) {
- /* simple overflow catcher. This will fail
- * terribly for non 32 or 64 bit counters
- * ... are there any others in SNMP land?
- */
- if (pdp_new[ds_idx] < (double) 0.0)
- pdp_new[ds_idx] += (double) 4294967296.0; /* 2^32 */
- if (pdp_new[ds_idx] < (double) 0.0)
- pdp_new[ds_idx] += (double) 18446744069414584320.0; /* 2^64-2^32 */
- }
- rate = pdp_new[ds_idx] / interval;
- } else {
- pdp_new[ds_idx] = DNAN;
- }
- break;
- case DST_ABSOLUTE:
- 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;
- };
- if (endptr[0] != '\0') {
- rrd_set_error("conversion of '%s' to float not complete: tail '%s'",
- updvals[ds_idx + 1], endptr);
- return -1;
- }
- rate = pdp_new[ds_idx] / interval;
- break;
- case DST_GAUGE:
- errno = 0;
- 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;
- };
- if (endptr[0] != '\0') {
- rrd_set_error("conversion of '%s' to float not complete: tail '%s'",
- updvals[ds_idx + 1], endptr);
- return -1;
- }
- rate = pdp_new[ds_idx] / interval;
- break;
- default:
- rrd_set_error("rrd contains unknown DS type : '%s'",
- rrd->ds_def[ds_idx].dst);
- return -1;
+ case DST_COUNTER:
+ case DST_DERIVE:
+ /* Check if this is a valid integer. `U' is already handled in
+ * another branch. */
+ for (ii = 0; updvals[ds_idx + 1][ii] != 0; ii++) {
+ if ((ii == 0) && (dst_idx == DST_DERIVE)
+ && (updvals[ds_idx + 1][ii] == '-'))
+ continue;
+
+ if ((updvals[ds_idx + 1][ii] < '0')
+ || (updvals[ds_idx + 1][ii] > '9')) {
+ rrd_set_error("not a simple %s integer: '%s'",
+ (dst_idx == DST_DERIVE) ? "signed" : "unsigned",
+ updvals[ds_idx + 1]);
+ return -1;
+ }
+ } /* for (ii = 0; updvals[ds_idx + 1][ii] != 0; ii++) */
+
+ if (rrd->pdp_prep[ds_idx].last_ds[0] != 'U') {
+ pdp_new[ds_idx] =
+ rrd_diff(updvals[ds_idx + 1],
+ rrd->pdp_prep[ds_idx].last_ds);
+ if (dst_idx == DST_COUNTER) {
+ /* simple overflow catcher. This will fail
+ * terribly for non 32 or 64 bit counters
+ * ... are there any others in SNMP land?
+ */
+ if (pdp_new[ds_idx] < (double) 0.0)
+ pdp_new[ds_idx] += (double) 4294967296.0; /* 2^32 */
+ if (pdp_new[ds_idx] < (double) 0.0)
+ pdp_new[ds_idx] += (double) 18446744069414584320.0; /* 2^64-2^32 */
+ }
+ rate = pdp_new[ds_idx] / interval;
+ } else {
+ pdp_new[ds_idx] = DNAN;
+ }
+ break;
+ case DST_ABSOLUTE:
+ old_locale = setlocale(LC_NUMERIC, NULL);
+ setlocale(LC_NUMERIC, "C");
+ errno = 0;
+ pdp_new[ds_idx] = strtod(updvals[ds_idx + 1], &endptr);
+ 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'",
+ updvals[ds_idx + 1], endptr);
+ return -1;
+ }
+ rate = pdp_new[ds_idx] / interval;
+ break;
+ case DST_GAUGE:
+ old_locale = setlocale(LC_NUMERIC, NULL);
+ setlocale(LC_NUMERIC, "C");
+ errno = 0;
+ pdp_new[ds_idx] =
+ strtod(updvals[ds_idx + 1], &endptr) * interval;
+ 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'",
+ updvals[ds_idx + 1], endptr);
+ return -1;
+ }
+ rate = pdp_new[ds_idx] / interval;
+ break;
+ default:
+ rrd_set_error("rrd contains unknown DS type : '%s'",
+ rrd->ds_def[ds_idx].dst);
+ return -1;