trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shinr...@apache.org
Subject [trafficserver] branch master updated: Avoid divide by zero in degenerate case.
Date Tue, 08 May 2018 12:18:06 GMT
This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c67067  Avoid divide by zero in degenerate case.
3c67067 is described below

commit 3c67067efb6244363959c3f532fd34b1e4ead105
Author: Susan Hinrichs <shinrich@oath.com>
AuthorDate: Mon May 7 14:25:18 2018 +0000

    Avoid divide by zero in degenerate case.
---
 cmd/traffic_cache_tool/CacheTool.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmd/traffic_cache_tool/CacheTool.cc b/cmd/traffic_cache_tool/CacheTool.cc
index 84e4e5f..c80e6a7 100644
--- a/cmd/traffic_cache_tool/CacheTool.cc
+++ b/cmd/traffic_cache_tool/CacheTool.cc
@@ -945,6 +945,7 @@ Cache::build_stripe_hash_table()
   unsigned int rtable_size     = 0;
   int i                        = 0;
   uint64_t used                = 0;
+
   // estimate allocation
   for (auto &elt : globalVec_stripe) {
     // printf("stripe length %" PRId64 "\n", elt->_len.count());
@@ -958,7 +959,7 @@ Cache::build_stripe_hash_table()
   }
   i = 0;
   for (auto &elt : globalVec_stripe) {
-    forvol[i] = static_cast<int64_t>(VOL_HASH_TABLE_SIZE * elt->_len) / total;
+    forvol[i] = total ? static_cast<int64_t>(VOL_HASH_TABLE_SIZE * elt->_len) /
total : 0;
     used += forvol[i];
     gotvol[i] = 0;
     i++;

-- 
To stop receiving notification emails like this one, please contact
shinrich@apache.org.

Mime
View raw message