From: Sage Weil Date: Wed, 31 May 2017 18:39:37 +0000 (-0400) Subject: common/entity_name: do not populate type_id string for type==0 X-Git-Tag: ses5-milestone6~9^2~9^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e19448c9f5dc86541050c74e497ca53246419da2;p=ceph.git common/entity_name: do not populate type_id string for type==0 The EntityName ctor leaves type == 0. If we encode and then decode that value, we end up calling set(), which tries (and fails) to populate the type_id string, leaving you with an instance that renders as 'unknown.' instead of ''. Signed-off-by: Sage Weil --- diff --git a/src/common/entity_name.cc b/src/common/entity_name.cc index becad3a12092..b50778c2ffd7 100644 --- a/src/common/entity_name.cc +++ b/src/common/entity_name.cc @@ -76,9 +76,13 @@ set(uint32_t type_, const std::string &id_) type = type_; id = id_; - std::ostringstream oss; - oss << ceph_entity_type_name(type_) << "." << id_; - type_id = oss.str(); + if (type) { + std::ostringstream oss; + oss << ceph_entity_type_name(type_) << "." << id_; + type_id = oss.str(); + } else { + type_id.clear(); + } } int EntityName::