]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
obj_bencher: possible divice by zero
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 01:21:08 +0000 (18:21 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:04 +0000 (13:18 -0700)
CID 716903: Division or modulo by zero (DIVIDE_BY_ZERO) [select defect]

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/obj_bencher.cc

index 5aec18dfe871c1f0fcde15663ddb7dd2b8ca4959..81d01f103041aa715beda7d255a92793e20c5fa9 100644 (file)
@@ -113,10 +113,13 @@ void *ObjBencher::status_printer(void *_bencher) {
           << setw(10) << "last lat"
           << setw(10) << "avg lat" << std::endl;
     }
-    bandwidth = (double)(data.finished - previous_writes)
-      * (data.trans_size)
-      / (1024*1024)
-      / cycleSinceChange;
+    if (cycleSinceChange)
+      bandwidth = (double)(data.finished - previous_writes)
+       * (data.trans_size)
+       / (1024*1024)
+       / cycleSinceChange;
+    else
+      bandwidth = 0;
 
     if (!isnan(bandwidth)) {
       if (bandwidth > data.idata.max_bandwidth)