X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_resize.c;h=efa84b0a3b57927406c9a1e33ffc0d416e5876fe;hp=39941c1cd4ada12fbf79bca413e44a904edb588a;hb=f207955a7e325708d056d3dd912863dc9930a71c;hpb=0b59fe0b8178d6f97788540c5983190ee6556586 diff --git a/src/rrd_resize.c b/src/rrd_resize.c index 39941c1..efa84b0 100644 --- a/src/rrd_resize.c +++ b/src/rrd_resize.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002 + * RRDtool 1.2rc6 Copyright by Tobi Oetiker, 1997-2005 ***************************************************************************** * rrd_resize.c Alters size of an RRA ***************************************************************************** @@ -69,7 +69,7 @@ rrd_resize(int argc, char **argv) } if (modify < 0) - if (rrdold.rra_def[target_rra].row_cnt <= -modify) { + if ((long)rrdold.rra_def[target_rra].row_cnt <= -modify) { rrd_set_error("This RRA is not that big"); rrd_free(&rrdold); fclose(infile); @@ -104,7 +104,7 @@ rrd_resize(int argc, char **argv) fwrite(rrdnew.rra_ptr,sizeof(rra_ptr_t),rrdnew.stat_head->rra_cnt,outfile); /* Move the CDPs from the old to the new database. - ** This can be made (much) faster but isn't worth the efford. Clarity + ** This can be made (much) faster but isn't worth the effort. Clarity ** is much more important. */ @@ -145,7 +145,7 @@ rrd_resize(int argc, char **argv) signed long int remove_end=0; remove_end=(rrdnew.rra_ptr[target_rra].cur_row-modify)%rrdnew.rra_def[target_rra].row_cnt; - if (remove_end <= rrdnew.rra_ptr[target_rra].cur_row) { + if (remove_end <= (signed long int)rrdnew.rra_ptr[target_rra].cur_row) { while (remove_end >= 0) { fseek(infile,sizeof(rrd_value_t)*rrdnew.stat_head->ds_cnt,SEEK_CUR); rrdnew.rra_ptr[target_rra].cur_row--; @@ -170,8 +170,10 @@ rrd_resize(int argc, char **argv) } /* Move the rest of the CDPs */ - while (!(feof(infile))) { - fread(&buffer,sizeof(rrd_value_t),1,infile); + while (1) { + fread(&buffer,sizeof(rrd_value_t),1,infile); + if (feof(infile)) + break; fwrite(&buffer,sizeof(rrd_value_t),1,outfile); } rrdnew.rra_def[target_rra].row_cnt += modify;