From: Kefu Chai Date: Mon, 5 Apr 2021 02:50:38 +0000 (+0800) Subject: msg/msg_types: pass TYPE_DEFAULT as default_type to entity_addr_t::parse() X-Git-Tag: v17.1.0~2361^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0b37c3b67a2ee3f21937ce26588dfb9e0c45fa25;p=ceph.git msg/msg_types: pass TYPE_DEFAULT as default_type to entity_addr_t::parse() 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 --- diff --git a/src/msg/msg_types.cc b/src/msg/msg_types.cc index ab4ee57177a4..0c28e915b7b0 100644 --- a/src/msg/msg_types.cc +++ b/src/msg/msg_types.cc @@ -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; diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h index 93927632f893..7b26ec5a2c66 100644 --- a/src/msg/msg_types.h +++ b/src/msg/msg_types.h @@ -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) {