]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/msg_types: pass TYPE_DEFAULT as default_type to entity_addr_t::parse()
authorKefu Chai <kchai@redhat.com>
Mon, 5 Apr 2021 02:50:38 +0000 (10:50 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 5 Apr 2021 04:33:01 +0000 (12:33 +0800)
TYPE_NONE equals to 0, and we use it for the default value of entity's
messenger protocol version, if it is not specified. but we always use
TYPE_DEFAULT for the protocol version if it's not specified in the
parsed string or the parameter.

so we can just simplify the logic by assigning it to `newtype`, and
assign the parse value to `new_type` for better readability.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/msg/msg_types.cc
src/msg/msg_types.h

index ab4ee57177a46ae3523b4709fd4e4feacaa1503e..0c28e915b7b0a85f76eb2842d621bffc28416fa0 100644 (file)
@@ -113,7 +113,7 @@ bool entity_addr_t::parse(const char *s, const char **end, int default_type)
     *end = s;
   }
 
-  int newtype;
+  int newtype = default_type;
   if (strncmp("v1:", s, 3) == 0) {
     start += 3;
     newtype = TYPE_LEGACY;
@@ -129,8 +129,6 @@ bool entity_addr_t::parse(const char *s, const char **end, int default_type)
       *end = s + 1;
     }
     return true;
-  } else {
-    newtype = default_type ? default_type : TYPE_DEFAULT;
   }
 
   bool brackets = false;
index 93927632f89367e305aa04b686ebcb5621c411ea..7b26ec5a2c66ebefe55f318597141dc01a4b899e 100644 (file)
@@ -408,7 +408,7 @@ struct entity_addr_t {
   }
 
   bool parse(const std::string_view s, int default_type=TYPE_DEFAULT);
-  bool parse(const char *s, const char **end = 0, int type=0);
+  bool parse(const char *s, const char **end = 0, int default_type=TYPE_DEFAULT);
 
   void decode_legacy_addr_after_marker(ceph::buffer::list::const_iterator& bl)
   {