summaryrefslogtreecommitdiff
path: root/t/btrace2fio.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-11-11 08:09:04 -0700
committerJens Axboe <axboe@fb.com>2014-11-11 08:09:04 -0700
commit97b32195d4713a13a17d409949fff5a08c4518dd (patch)
tree149c5dc0c3d20aa6864b8c971179da75f303399a /t/btrace2fio.c
parentb295dc29b3abebe968950ce792f3087077223b78 (diff)
downloadfio-97b32195d4713a13a17d409949fff5a08c4518dd.tar.gz
fio-97b32195d4713a13a17d409949fff5a08c4518dd.tar.bz2
t/btrace2fio: fix divide-by-zero in rate calculation
If usec is less than 1000, it'd crash. Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 't/btrace2fio.c')
-rw-r--r--t/btrace2fio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/t/btrace2fio.c b/t/btrace2fio.c
index bf67ed0a..efe25c4c 100644
--- a/t/btrace2fio.c
+++ b/t/btrace2fio.c
@@ -549,8 +549,12 @@ static unsigned long o_to_kb_rate(struct btrace_out *o, int rw)
if (!usec)
return 0;
+ usec /= 1000;
+ if (!usec)
+ return 0;
+
val = o->kb[rw] * 1000ULL;
- return val / (usec / 1000ULL);
+ return val / usec;
}
static uint64_t o_first_ttime(struct btrace_out *o)