steadystate: check for division by zero in mean calculation
authorJens Axboe <axboe@kernel.dk>
Sun, 8 Apr 2018 21:54:26 +0000 (15:54 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 8 Apr 2018 21:54:26 +0000 (15:54 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
steadystate.c

index 1e3a546..ee1c0e5 100644 (file)
@@ -350,6 +350,9 @@ uint64_t steadystate_bw_mean(struct thread_stat *ts)
        int i;
        uint64_t sum;
 
+       if (!ts->ss_dur)
+               return 0;
+
        for (i = 0, sum = 0; i < ts->ss_dur; i++)
                sum += ts->ss_bw_data[i];
 
@@ -361,6 +364,9 @@ uint64_t steadystate_iops_mean(struct thread_stat *ts)
        int i;
        uint64_t sum;
 
+       if (!ts->ss_dur)
+               return 0;
+
        for (i = 0, sum = 0; i < ts->ss_dur; i++)
                sum += ts->ss_iops_data[i];