From: Jens Axboe Date: Wed, 15 Oct 2014 01:47:41 +0000 (-0600) Subject: crc/test: fix potential div by zero X-Git-Tag: fio-2.1.14~57 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e5607fe5385523d6029d21883f51fe0053abb5aa;p=fio.git crc/test: fix potential div by zero Signed-off-by: Jens Axboe --- diff --git a/crc/test.c b/crc/test.c index bca46f24..bc5cc456 100644 --- a/crc/test.c +++ b/crc/test.c @@ -329,13 +329,16 @@ int fio_crctest(const char *type) t[i].fn(&t[i], buf, CHUNK); usec = utime_since_now(&tv); - mb_sec = (double) mb / (double) usec; - mb_sec /= (1.024 * 1.024); - if (strlen(t[i].name) >= 7) - sprintf(pre, "\t"); - else - sprintf(pre, "\t\t"); - printf("%s:%s%8.2f MB/sec\n", t[i].name, pre, mb_sec); + if (usec) { + mb_sec = (double) mb / (double) usec; + mb_sec /= (1.024 * 1.024); + if (strlen(t[i].name) >= 7) + sprintf(pre, "\t"); + else + sprintf(pre, "\t\t"); + printf("%s:%s%8.2f MB/sec\n", t[i].name, pre, mb_sec); + } else + printf("%s:inf MB/sec\n", t[i].name); first = 0; }