]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Monitor: remove unused variable
authorKefu Chai <kchai@redhat.com>
Thu, 10 Dec 2020 09:06:00 +0000 (17:06 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 11 Dec 2020 08:12:50 +0000 (16:12 +0800)
and add error handling

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/Monitor.cc

index d28e21a746f759c8db6d375fe391bb165d8fd6ce..c2198638de2498b6442acf42e25e3f9b84a4aa51 100644 (file)
@@ -5378,11 +5378,13 @@ void Monitor::get_all_versions(std::map<string, list<string> > &versions)
 
 void Monitor::get_versions(std::map<string, list<string> > &versions)
 {
-  int i = 0;
   for (auto& [rank, metadata] : mon_metadata) {
     auto q = metadata.find("ceph_version_short");
+    if (q == metadata.end()) {
+      // not likely
+      continue;
+    }
     versions[q->second].push_back(string("mon.") + monmap->get_name(rank));
-    i = i + 1;
   }
 }