Code

check row count in RRAs to be > 0 ... by Sebastian Harl
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Tue, 10 Jun 2008 09:35:03 +0000 (09:35 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Tue, 10 Jun 2008 09:35:03 +0000 (09:35 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1424 a5681a0c-68f1-0310-ab6d-d61299d08faa

doc/rrdcreate.pod
src/rrd_create.c

index 86817bd4dbeb60bc0c9233244744cd41e7e20165..03012e035e2739ce6eae79584fcc191844d44acb 100644 (file)
@@ -216,6 +216,7 @@ I<steps> defines how many of these I<primary data points> are used to build
 a I<consolidated data point> which then goes into the archive.
 
 I<rows> defines how many generations of data values are kept in an B<RRA>.
+Obviously, this has to be greater than zero.
 
 =back
 
index 028123ef46f4a65ce2704a755b8fd0d5e7dbf1fa..6d7cb18e977af78a55a2afc55069d5923e1084d8 100644 (file)
@@ -232,6 +232,7 @@ int rrd_create_r(
             char     *argvcopy;
             char     *tokptr;
             size_t    old_size = sizeof(rra_def_t) * (rrd.stat_head->rra_cnt);
+            int       row_cnt;
 
             if ((rrd.rra_def = rrd_realloc(rrd.rra_def,
                                            old_size + sizeof(rra_def_t))) ==
@@ -312,8 +313,10 @@ int rrd_create_r(
                     case CF_SEASONAL:
                     case CF_DEVPREDICT:
                     case CF_FAILURES:
-                        rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt =
-                            atoi(token);
+                        row_cnt = atoi(token);
+                        rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = row_cnt;
+                        if (row_cnt <= 0)
+                            rrd_set_error("Invalid row count: %i", row_cnt);
                         break;
                     default:
                         rrd.rra_def[rrd.stat_head->rra_cnt].
@@ -416,8 +419,10 @@ int rrd_create_r(
                             ("Unexpected extra argument for consolidation function DEVPREDICT");
                         break;
                     default:
-                        rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt =
-                            atoi(token);
+                        row_cnt = atoi(token);
+                        rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = row_cnt;
+                        if (row_cnt <= 0)
+                            rrd_set_error("Invalid row count: %i", row_cnt);
                         break;
                     }
                     break;