From 163e2cf8a6b3262cd949aebec8e62313cf11c9ee Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 18 Jul 2017 16:39:09 -0700 Subject: [PATCH] mds: cleanup with unique_ptr Signed-off-by: Patrick Donnelly --- src/mds/MDSDaemon.cc | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 6ec8ab471b1..6947cd2b63e 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -15,17 +15,23 @@ #include #include "include/compat.h" -#include "global/signal_handler.h" - #include "include/types.h" #include "include/str_list.h" -#include "common/entity_name.h" + #include "common/Clock.h" -#include "common/signal.h" +#include "common/HeartbeatMap.h" +#include "common/Timer.h" +#include "common/backport14.h" #include "common/ceph_argparse.h" +#include "common/config.h" +#include "common/entity_name.h" #include "common/errno.h" +#include "common/perf_counters.h" +#include "common/signal.h" #include "common/version.h" +#include "global/signal_handler.h" + #include "msg/Messenger.h" #include "mon/MonClient.h" @@ -40,12 +46,6 @@ #include "SnapServer.h" #include "SnapClient.h" -#include "common/HeartbeatMap.h" - -#include "common/perf_counters.h" - -#include "common/Timer.h" - #include "events/ESession.h" #include "events/ESubtreeMap.h" @@ -61,8 +61,6 @@ #include "auth/RotatingKeyRing.h" #include "auth/KeyRing.h" -#include "common/config.h" - #include "perfglue/cpu_profiler.h" #include "perfglue/heap_profiler.h" @@ -730,33 +728,31 @@ int MDSDaemon::_handle_command( std::stringstream ss; std::string prefix; std::string format; - boost::scoped_ptr f; + std::unique_ptr f(Formatter::create(format)); cmd_getval(cct, cmdmap, "prefix", prefix); int r = 0; if (prefix == "get_command_descriptions") { int cmdnum = 0; - JSONFormatter *f = new JSONFormatter(); + std::unique_ptr f(ceph::make_unique()); f->open_object_section("command_descriptions"); for (MDSCommand *cp = mds_commands; cp < &mds_commands[ARRAY_SIZE(mds_commands)]; cp++) { ostringstream secname; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; - dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, + dump_cmddesc_to_json(f.get(), secname.str(), cp->cmdstring, cp->helpstring, cp->module, cp->perm, cp->availability, 0); cmdnum++; } f->close_section(); // command_descriptions f->flush(ds); - delete f; goto out; } - + cmd_getval(cct, cmdmap, "format", format); - f.reset(Formatter::create(format)); if (prefix == "version") { if (f) { f->open_object_section("version"); -- 2.47.3