]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: use unique_ptr for Formatter
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 16 Mar 2017 18:32:01 +0000 (14:32 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 20 Sep 2017 23:15:58 +0000 (16:15 -0700)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/client/Client.cc

index 7a218824f9e1a0b2ed9e0d670a8f455d8ffc760f..c46cd1e12b63eb96c57362667f269997e27ed95c 100644 (file)
@@ -139,25 +139,24 @@ Client::CommandHook::CommandHook(Client *client) :
 bool Client::CommandHook::call(std::string command, cmdmap_t& cmdmap,
                               std::string format, bufferlist& out)
 {
-  Formatter *f = Formatter::create(format);
+  std::unique_ptr<Formatter> f(Formatter::create(format));
   f->open_object_section("result");
   m_client->client_lock.Lock();
   if (command == "mds_requests")
-    m_client->dump_mds_requests(f);
+    m_client->dump_mds_requests(f.get());
   else if (command == "mds_sessions")
-    m_client->dump_mds_sessions(f);
+    m_client->dump_mds_sessions(f.get());
   else if (command == "dump_cache")
-    m_client->dump_cache(f);
+    m_client->dump_cache(f.get());
   else if (command == "kick_stale_sessions")
     m_client->_kick_stale_sessions();
   else if (command == "status")
-    m_client->dump_status(f);
+    m_client->dump_status(f.get());
   else
     assert(0 == "bad command registered");
   m_client->client_lock.Unlock();
   f->close_section();
   f->flush(out);
-  delete f;
   return true;
 }