]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_common: introduce a decode_bl function to decode a bl to type
authorAbhishek Lekshmanan <abhishek@suse.com>
Fri, 3 May 2019 12:53:27 +0000 (14:53 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 6 May 2019 09:51:57 +0000 (11:51 +0200)
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_common.h

index 8ff03a554dcd6fb272cd044f6357eb00aa90cd42..fbd1b4dc72661eb893ffead53c45402e5b0a0424 100644 (file)
@@ -2669,4 +2669,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