From: Dan van der Ster Date: Fri, 30 Apr 2021 06:31:07 +0000 (+0200) Subject: nautilus: mon: ensure progress is [0,1] before printing X-Git-Tag: v14.2.22~29^2~3^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F41098%2Fhead;p=ceph.git nautilus: mon: ensure progress is [0,1] before printing Ensure that progress is in the expected range [0,1] before rendering a progress bar. Nautilus only because this is avoided in future releases thanks to 5f95ec4457059889bc4dbc2ad25cdc0537255f69. Related-to: https://tracker.ceph.com/issues/50587 Signed-off-by: Dan van der Ster --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index edf3b78933dd7..bda34a44be0e1 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3063,8 +3063,14 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) for (auto& i : pem) { ss << " " << i.second.message << "\n"; ss << " ["; + unsigned p; + if (i.second.progress >= 0.0 && i.second.progress <= 1.0) { + p = (unsigned)(i.second.progress * 30.0); + } else { + p = 0; + } unsigned j; - for (j = 0; j < (unsigned)(i.second.progress * 30.0); ++j) { + for (j = 0; j < p; ++j) { ss << '='; } for (; j < 30; ++j) {