Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd/osdmap: fix divide by zero error #12521

Merged
merged 1 commit into from Dec 16, 2016
Merged

osd/osdmap: fix divide by zero error #12521

merged 1 commit into from Dec 16, 2016

Conversation

wycbox
Copy link

@wycbox wycbox commented Dec 16, 2016

*** 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, std::allocator> *,
std::__cxx11::basic_string<char, std::char_traits,
std::allocator> *, 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

*** 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>
@liewegas liewegas changed the title osdmap: fix divide by zero error osd/osdmap: fix divide by zero error Dec 16, 2016
@liewegas liewegas merged commit 15fdc67 into ceph:master Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants