]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src: use entity_addr_t::parse(string_view) when possible
authorKefu Chai <kchai@redhat.com>
Mon, 5 Apr 2021 03:11:03 +0000 (11:11 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 5 Apr 2021 04:33:04 +0000 (12:33 +0800)
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/ceph_mon.cc
src/common/cmdparse.cc
src/common/options.cc
src/common/pick_address.cc
src/librados/RadosClient.cc
src/mon/Monitor.cc
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc
src/tools/rbd/action/Kernel.cc

index a468d8b9d16d29b8b2dc0c13c697a5ddb6921371..306d663d33a883d95c7800f4869108dd82b9c766 100644 (file)
@@ -747,7 +747,7 @@ int main(int argc, const char **argv)
     if (g_conf().get_val_from_conf_file(my_sections, "mon addr",
                                       mon_addr_str, true) == 0) {
       entity_addr_t conf_addr;
-      if (conf_addr.parse(mon_addr_str.c_str())) {
+      if (conf_addr.parse(mon_addr_str)) {
        entity_addrvec_t conf_addrs = make_mon_addrs(conf_addr);
         if (ipaddrs != conf_addrs) {
          derr << "WARNING: 'mon addr' config option " << conf_addrs
index b8cf316340de5c8b0e685eee7c56ae03b018ffbd..f1756a292a5215ec8b3bd978873d18778d7704f0 100644 (file)
@@ -526,7 +526,7 @@ bool validate_str_arg(std::string_view value,
 {
   if (type == "CephIPAddr") {
     entity_addr_t addr;
-    if (addr.parse(string(value).c_str())) {
+    if (addr.parse(value)) {
       return true;
     } else {
       os << "failed to parse addr '" << value << "', should be ip:[port]";
index 4a70c85dbf22d9149244c13eb3761b1a191d5d62..73b7a8c0e9e88d0d0a12a68604a1e9f81fe02b27 100644 (file)
@@ -178,7 +178,7 @@ int Option::parse_value(
     }
   } else if (type == Option::TYPE_ADDR) {
     entity_addr_t addr;
-    if (!addr.parse(val.c_str())){
+    if (!addr.parse(val)){
       return -EINVAL;
     }
     *out = addr;
index ff7c32c4b7a4d762e8e046b7296270431baee476..47f8875e0cedf7bd87192498d65c3c7e9918afbf 100644 (file)
@@ -303,8 +303,7 @@ static int fill_in_one_address(
   }
 
   entity_addr_t addr;
-  const char *end = 0;
-  bool r = addr.parse(buf, &end);
+  bool r = addr.parse(buf);
   if (!r) {
     return -1;
   }
index 47b928058c4f565786c81680a97fba68cc3636c6..29f240440aeabcf842873408fc0d95abb21f389f 100644 (file)
@@ -773,7 +773,7 @@ int librados::RadosClient::blocklist_add(const string& client_address,
                                         uint32_t expire_seconds)
 {
   entity_addr_t addr;
-  if (!addr.parse(client_address.c_str(), 0)) {
+  if (!addr.parse(client_address)) {
     lderr(cct) << "unable to parse address " << client_address << dendl;
     return -EINVAL;
   }
index a4bef49690f28b34bce6dcf83a19d79340203702..6126db9caa6090747b5be8168d1a7a162542c1c9 100644 (file)
@@ -1280,8 +1280,7 @@ bool Monitor::_add_bootstrap_peer_hint(std::string_view cmd,
             << addrstr << "'" << dendl;
 
     entity_addr_t addr;
-    const char *end = 0;
-    if (!addr.parse(addrstr.c_str(), &end, entity_addr_t::TYPE_ANY)) {
+    if (!addr.parse(addrstr, entity_addr_t::TYPE_ANY)) {
       ss << "failed to parse addrs '" << addrstr
         << "'; syntax is 'add_bootstrap_peer_hint ip[:port]'";
       return false;
index ec72f410d1fcf230384748abc1a367052a446799..daeb4b572fd7b84fd77ca4a89308012364cedb33 100644 (file)
@@ -584,7 +584,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
     entity_addr_t addr;
     bufferlist rdata;
 
-    if (!addr.parse(addrstr.c_str())) {
+    if (!addr.parse(addrstr)) {
       err = -EINVAL;
       ss << "addr " << addrstr << "does not parse";
       goto reply;
index 521d57899e059fae527e838f185f55599f2d5bfe..656499c59d0f167bf6066375a63035a893e13fab 100644 (file)
@@ -12520,7 +12520,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     string addrstr;
     cmd_getval(cmdmap, "addr", addrstr);
     entity_addr_t addr;
-    if (!addr.parse(addrstr.c_str(), 0)) {
+    if (!addr.parse(addrstr)) {
       ss << "unable to parse address " << addrstr;
       err = -EINVAL;
       goto reply;
index 3ed8e59037b0950042971587369030cb6ea1d6aa..55bd23ba6df1a5ebdb5f8d7a3911d3e6322bdb1d 100644 (file)
@@ -41,9 +41,7 @@ static std::string map_option_uuid_cb(const char *value_char)
 static std::string map_option_ip_cb(const char *value_char)
 {
   entity_addr_t a;
-  const char *endptr;
-  if (!a.parse(value_char, &endptr) ||
-      endptr != value_char + strlen(value_char)) {
+  if (!a.parse(value_char)) {
     return "";
   }