From 5e56ea6f0778973cdbb90eaf643fba1240af3f8b Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Fri, 3 May 2019 14:53:27 +0200 Subject: [PATCH] rgw_common: introduce a decode_bl function to decode a bl to type Signed-off-by: Abhishek Lekshmanan --- src/rgw/rgw_common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 8ff03a554dcd6..fbd1b4dc72661 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -2669,4 +2669,16 @@ static inline string rgw_bl_str(ceph::buffer::list& raw) return s; } +template +int decode_bl(bufferlist& bl, T& t) +{ + auto iter = bl.cbegin(); + try { + decode(t, iter); + } catch (buffer::error& err) { + return -EIO; + } + return 0; +} + #endif -- 2.39.5