From e19448c9f5dc86541050c74e497ca53246419da2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 31 May 2017 14:39:37 -0400 Subject: [PATCH] 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 --- src/common/entity_name.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/entity_name.cc b/src/common/entity_name.cc index becad3a120923..b50778c2ffd7e 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:: -- 2.39.5