]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/entity_name: do not populate type_id string for type==0
authorSage Weil <sage@redhat.com>
Wed, 31 May 2017 18:39:37 +0000 (14:39 -0400)
committerSage Weil <sage@redhat.com>
Wed, 31 May 2017 18:39:54 +0000 (14:39 -0400)
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 <sage@redhat.com>
src/common/entity_name.cc

index becad3a1209231c78a29e6c540053955c16a261d..b50778c2ffd7e01d7eac25bd6c2fbdc26fa95ced 100644 (file)
@@ -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::