]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_common.h
import ceph nautilus 14.2.2
[ceph.git] / ceph / src / rgw / rgw_common.h
index d558b6bdc2e426ffa7bd4d89fbb3535fbc636c06..a7347a473cba33e7f4b71a6ee5d6b65c931c95e3 100644 (file)
@@ -695,7 +695,7 @@ struct rgw_placement_rule {
 
   void encode(bufferlist& bl) const {
     /* no ENCODE_START/END due to backward compatibility */
-    std::string s = to_str_explicit();
+    std::string s = to_str();
     ceph::encode(s, bl);
   }
 
@@ -720,12 +720,11 @@ struct rgw_placement_rule {
     size_t pos = s.find("/");
     if (pos == std::string::npos) {
       name = s;
+      storage_class.clear();
       return;
     }
     name = s.substr(0, pos);
-    if (pos < s.size() - 1) {
-      storage_class = s.substr(pos + 1);
-    }
+    storage_class = s.substr(pos + 1);
   }
 
   bool standard_storage_class() const {
@@ -2668,4 +2667,16 @@ static inline string rgw_bl_str(ceph::buffer::list& raw)
   return s;
 }
 
+template <typename T>
+int decode_bl(bufferlist& bl, T& t)
+{
+  auto iter = bl.cbegin();
+  try {
+    decode(t, iter);
+  } catch (buffer::error& err) {
+    return -EIO;
+  }
+  return 0;
+}
+
 #endif