From: Abhishek Lekshmanan Date: Fri, 3 May 2019 12:53:27 +0000 (+0200) Subject: rgw_common: introduce a decode_bl function to decode a bl to type X-Git-Tag: v14.2.2~16^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2d877210fed2dceefa34f39321ba9ba8e80ba33f;p=ceph.git rgw_common: introduce a decode_bl function to decode a bl to type Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 5e56ea6f0778973cdbb90eaf643fba1240af3f8b) --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index d558b6bdc2e..075fd02d5bd 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -2668,4 +2668,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