]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix nasty off-by-one error, causing incorrect CDP calculations when adding
authorPeter Stamfest <peter@stamfest.at>
Thu, 6 Mar 2014 07:26:06 +0000 (08:26 +0100)
committerPeter Stamfest <peter@stamfest.at>
Thu, 6 Mar 2014 07:26:06 +0000 (08:26 +0100)
new RRAs

src/rrd_modify.c
tests/modify5

index f7a6beac56ae3f216df6572b6a41d409cd5266ec..b1447bba5cc59f029e067742f72507c6db825f2c 100644 (file)
@@ -1039,7 +1039,9 @@ static void prepare_CDPs(const rrd_t *in, rrd_t *out,
            }
        }
     }
-
+#ifdef MODIFY_DEBUG
+    fprintf(stderr, "chosen candidate index=%d row_cnt=%ld\n", chosen_candidate->rra_index, chosen_candidate->rra->row_cnt);
+#endif
     int start_cdp_index_out = out->stat_head->ds_cnt * curr_rra;
 
     for (int i = 0 ; i < (int) out->stat_head->ds_cnt ; i++) {
@@ -1132,7 +1134,7 @@ static void prepare_CDPs(const rrd_t *in, rrd_t *out,
                    ccdp->scratch[CDP_primary_val].u_val;
            } else {
                int pre_start = start_row - 1;
-               if (pre_start == 0) pre_start = chosen_candidate->rra->row_cnt;
+               if (pre_start < 0) pre_start = chosen_candidate->rra->row_cnt - 1;
 
                cdp_prep->scratch[CDP_secondary_val].u_val = 
                    chosen_candidate->values[ds_cnt * pre_start + mapped_i];
index b134293667dda3ba2cb7e9fb9d0693faa01b53e4..bbf00dca5105d1e22d93e38fe6bf279f21fb620e 100755 (executable)
@@ -29,7 +29,7 @@ report create 1
 $RRDTOOL dump ${BASE}a2.rrd | $DIFF ${BASE}a2-create.dump -
 report create 2
 
-for U in 1300003010:200 1300003070:102 1300003130:777 1300003190:645 1300003250:122 1300003310:981 1300003323:223 1300003381:721
+for U in 1300003010:200 1300003070:102 1300003130:777 1300003190:645 1300003250:122 1300003310:981 1300003323:223 1300003381:721 1300003445:821 1300003500:221 1300003562:231 1300003637:542 1300003699:734 1300003769:9231 1300003823:17
 do
        echo ---------------------iterate--------------------------
        # update both - both contain same data