]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
osdmap: fix divide by zero error 12520/head 12521/head
authorYunchuan Wen <yunchuan.wen@kylin-cloud.com>
Fri, 16 Dec 2016 09:28:35 +0000 (17:28 +0800)
committerYunchuan Wen <yunchuan.wen@kylin-cloud.com>
Fri, 16 Dec 2016 09:28:35 +0000 (17:28 +0800)
commit61d3e4f38c8f620d2c90afbc90a730d631d0df13
treecad37530b28d5aec8d89112fa592a8d88103d768
parent8d7d5ae3ff601153cfe6724cceb0fe767557344d
osdmap: fix divide by zero error

*** CID 1397255:  Incorrect expression  (DIVIDE_BY_ZERO)
/home/brad/working/src/ceph/src/osd/OSDMap.cc: 2995 in
OSDMap::summarize_mapping_stats(OSDMap*, const std::set<long,
std::less<long>, std::allocator<long>> *,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>> *, ceph::Formatter *) const()
2989         f->open_object_section("utilization");
2990       if (newmap) {
2991         if (f) {
2992           f->dump_unsigned("moved_pgs", moved_pg);
2993           f->dump_unsigned("total_pgs", total_pg);
2994         } else {
>>>     CID 1397255:  Incorrect expression  (DIVIDE_BY_ZERO)
>>>     In expression "(float)moved_pg * 100. / (float)total_pg",
division by expression "total_pg" which may be zero has undefined
behavior.
2995           ss << "moved " << moved_pg << " / " << total_pg
2996       << " (" << ((float)moved_pg * 100.0 / (float)total_pg) <<
"%)\n";
2997         }
2998       }
2999       if (f) {
3000         f->dump_float("avg_pgs", avg_pg);

Signed-off-by: Yunchuan Wen <yunchuan.wen@kylin-cloud.com>
src/osd/OSDMap.cc