From: Jens Axboe Date: Mon, 14 Apr 2014 15:49:38 +0000 (-0600) Subject: stat: fix potential divide-by-zero X-Git-Tag: fio-2.1.9~47 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=0956264f3dca6a0467092fe9ef335f3cae1c6177;p=fio.git stat: fix potential divide-by-zero Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index ca733108..1ef88ddf 100644 --- a/stat.c +++ b/stat.c @@ -1803,7 +1803,11 @@ void add_bw_sample(struct thread_data *td, enum fio_ddir ddir, unsigned int bs, if (!delta) continue; /* No entries for interval */ - rate = delta * 1000 / spent / 1024; + if (spent) + rate = delta * 1000 / spent / 1024; + else + rate = 0; + add_stat_sample(&ts->bw_stat[ddir], rate); if (td->bw_log) @@ -1838,7 +1842,11 @@ void add_iops_sample(struct thread_data *td, enum fio_ddir ddir, unsigned int bs if (!delta) continue; /* No entries for interval */ - iops = (delta * 1000) / spent; + if (spent) + iops = (delta * 1000) / spent; + else + iops = 0; + add_stat_sample(&ts->iops_stat[ddir], iops); if (td->iops_log)