stat: NaN fixes
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/stat.c b/stat.c
index 851cc2c..40e3b1b 100644
--- a/stat.c
+++ b/stat.c
@@ -440,12 +440,14 @@
ts->percentile_list);
}
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
- double p_of_agg;
+ double p_of_agg = 100.0;
const char *bw_str = "KB";
- p_of_agg = mean * 100 / (double) rs->agg[ddir];
- if (p_of_agg > 100.0)
- p_of_agg = 100.0;
+ if (rs->agg[dir]) {
+ p_of_agg = mean * 100 / (double) rs->agg[ddir];
+ if (p_of_agg > 100.0)
+ p_of_agg = 100.0;
+ }
if (mean > 999999.9) {
min /= 1000.0;
@@ -653,9 +655,14 @@
free(ovals);
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
- double p_of_agg;
+ double p_of_agg = 100.0;
- p_of_agg = mean * 100 / (double) rs->agg[ddir];
+ if (rs->agg[ddir]) {
+ p_of_agg = mean * 100 / (double) rs->agg[ddir];
+ if (p_of_agg > 100.0)
+ p_of_agg = 100.0;
+ }
+
log_info(";%lu;%lu;%f%%;%f;%f", min, max, p_of_agg, mean, dev);
} else
log_info(";%lu;%lu;%f%%;%f;%f", 0UL, 0UL, 0.0, 0.0, 0.0);