summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 700672a)
raw | patch | inline | side by side (parent: 700672a)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 14 Jan 2010 13:01:43 +0000 (13:01 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 14 Jan 2010 13:01:43 +0000 (13:01 +0000) |
program/src/rrd_update.c | patch | blob | history |
index 1a6d2ef52d712a62b15081b240911e89acc54352..37da5eda37a0d3827cff401b8830126b008a9b5d 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
switch (dst_idx) {
case DST_COUNTER:
case DST_DERIVE:
- if ( ( updvals[ds_idx + 1][0] < '0'
- || updvals[ds_idx + 1][0] > '9' )
- && updvals[ds_idx + 1][0] != '-'
- && updvals[ds_idx + 1][0] != 'U'
- ) {
- rrd_set_error("not a simple integer: '%s'",
- updvals[ds_idx + 1]);
- return -1;
- }
- for (ii = 1; updvals[ds_idx + 1][ii] != '\0'; ii++) {
- if ( updvals[ds_idx + 1][ii] < '0'
- || updvals[ds_idx + 1][ii] > '9'
- ) {
- rrd_set_error("not a simple integer: '%s'",
- updvals[ds_idx + 1]);
+ /* 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],