summaryrefslogtreecommitdiff
path: root/crc
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-10-14 19:47:41 -0600
committerJens Axboe <axboe@fb.com>2014-10-14 19:47:41 -0600
commite5607fe5385523d6029d21883f51fe0053abb5aa (patch)
tree0b26ab7d1244126703f273203996c59e2eb3f2e2 /crc
parentd36b072de874db57b585993c6c3b475f34ecad58 (diff)
downloadfio-e5607fe5385523d6029d21883f51fe0053abb5aa.tar.gz
fio-e5607fe5385523d6029d21883f51fe0053abb5aa.tar.bz2
crc/test: fix potential div by zero
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'crc')
-rw-r--r--crc/test.c17
1 files changed, 10 insertions, 7 deletions
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;
}