From ca980a63c3125a356cff79eba9df06fd2b37d731 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Wed, 22 Nov 2017 17:20:58 +0530 Subject: [PATCH] pybind: return error message when ceph_mds_command() returns error Returned the error message when ceph_mds_command() returns error. Signed-off-by: Jos Collin (cherry picked from commit 941b58c968f6b0e359f279c8bc9e7decf51e75d1) --- src/pybind/cephfs/cephfs.pyx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 806e0ab4c375..3f106c4dfc6a 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -962,10 +962,10 @@ cdef class LibCephFS(object): char *_inbuf = input_data size_t _inbuf_len = len(input_data) - char *_outbuf - size_t _outbuf_len - char *_outs - size_t _outs_len + char *_outbuf = NULL + size_t _outbuf_len = 0 + char *_outs = NULL + size_t _outs_len = 0 try: with nogil: @@ -974,15 +974,12 @@ cdef class LibCephFS(object): _inbuf, _inbuf_len, &_outbuf, &_outbuf_len, &_outs, &_outs_len) - if ret == 0: - my_outs = decode_cstr(_outs[:_outs_len]) - my_outbuf = _outbuf[:_outbuf_len] - if _outs_len: - ceph_buffer_free(_outs) - if _outbuf_len: - ceph_buffer_free(_outbuf) - return (ret, my_outbuf, my_outs) - else: - return (ret, b"", "") + my_outs = decode_cstr(_outs[:_outs_len]) + my_outbuf = _outbuf[:_outbuf_len] + if _outs_len: + ceph_buffer_free(_outs) + if _outbuf_len: + ceph_buffer_free(_outbuf) + return (ret, my_outbuf, my_outs) finally: free(_cmd) -- 2.47.3