You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/09/28 13:18:44 UTC

[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #924: Use ParseInt to replace sto*, ato*

git-hulk commented on code in PR #924:
URL: https://github.com/apache/incubator-kvrocks/pull/924#discussion_r982394380


##########
src/redis_cmd.cc:
##########
@@ -4495,15 +4497,11 @@ class CommandReplConf : public Commander {
 
   Status ParseParam(const std::string &option, const std::string &value) {
     if (option == "listening-port") {
-      try {
-        auto p = std::stoul(value);
-        if (p > UINT32_MAX) {
-          throw std::overflow_error("listening-port out of range");
-        }
-        port_ = static_cast<uint32_t>(p);
-      } catch (const std::exception &e) {
-        return Status(Status::RedisParseErr, "listening-port should be number");
+      auto parse_result = ParseInt<uint32_t>(value, 10);
+      if (!parse_result) {
+          return Status(Status::RedisParseErr, "listening-port should be number");
       }
+      port_ = *parse_result;

Review Comment:
   Need to check the port range here



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org