empiredan commented on code in PR #1241:
URL: 
https://github.com/apache/incubator-pegasus/pull/1241#discussion_r1022703672


##########
src/utils/command_manager.cpp:
##########
@@ -24,48 +24,50 @@
  * THE SOFTWARE.
  */
 
+#include "utils/command_manager.h"
+
 #include <iostream>
 #include <sstream>
 #include <thread>
 
-#include "utils/command_manager.h"
 #include "utils/fmt_logging.h"
+#include "utils/smart_pointers.h"
 #include "utils/utils.h"
 
 namespace dsn {
 
-dsn_handle_t command_manager::register_command(const std::vector<std::string> 
&commands,
-                                               const std::string 
&help_one_line,
-                                               const std::string &help_long,
-                                               command_handler handler)
+std::unique_ptr<command_deregister>
+command_manager::register_command(const std::vector<std::string> &commands,
+                                  const std::string &help_one_line,
+                                  const std::string &help_long,
+                                  command_handler handler)
 {
     utils::auto_write_lock l(_lock);
     bool is_valid_cmd = false;
-
     for (const std::string &cmd : commands) {
         if (!cmd.empty()) {
             is_valid_cmd = true;
-            auto it = _handlers.find(cmd);
-            CHECK(it == _handlers.end(), "command '{}' already regisered", 
cmd);
+            CHECK(_handlers.find(cmd) == _handlers.end(), "command '{}' 
already regisered", cmd);
         }
     }
     CHECK(is_valid_cmd, "should not register empty command");
 
     command_instance *c = new command_instance();
     c->commands = commands;
-    c->help_long = help_long;
     c->help_short = help_one_line;
+    c->help_long = help_long;
     c->handler = handler;
 
     for (const std::string &cmd : commands) {
         if (!cmd.empty()) {
             _handlers[cmd] = c;
         }
     }
-    return c;
+
+    return dsn::make_unique<command_deregister>(static_cast<uintptr_t>(c));

Review Comment:
   ```suggestion
       return 
dsn::make_unique<command_deregister>(reinterpret_cast<uintptr_t>(c));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to