From 356c919531b3134be5d74b3d8e13b8f2823a485e Mon Sep 17 00:00:00 2001 From: Willem Jan Withagen Date: Tue, 20 Jun 2017 15:52:06 +0200 Subject: [PATCH] core: make the conversion from wire error to host OS work - The key change is the type of rval, that will call the conversion when en/decoded - Remainder is fixes for the type change and promotions Signed-off-by: Willem Jan Withagen --- src/common/freebsd_errno.cc | 2 +- src/include/types.h | 11 +++++++---- src/osd/osd_types.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/freebsd_errno.cc b/src/common/freebsd_errno.cc index 77f6df91e9b92..259ce7be796ff 100644 --- a/src/common/freebsd_errno.cc +++ b/src/common/freebsd_errno.cc @@ -201,7 +201,7 @@ __s32 ceph_to_hostos_errno(__s32 r) { int sign = (r < 0 ? -1 : 1); int err = std::abs(r); - if (err < 256 && hostos_to_ceph_conv[err] !=0 ) { + if (err < 256 && ceph_to_hostos_conv[err] !=0 ) { err = ceph_to_hostos_conv[err]; } return err * sign; diff --git a/src/include/types.h b/src/include/types.h index deb794cbdfd70..371f884f82e85 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -489,10 +489,13 @@ struct errorcode32_t { // cppcheck-suppress noExplicitConstructor errorcode32_t(int32_t i) : code(i) {} - operator int() const { return code; } - int operator==(int i) { - return code==i; - } + operator int() const { return code; } + int* operator&() { return &code; } + int operator==(int i) { return code == i; } + int operator>(int i) { return code > i; } + int operator>=(int i) { return code >= i; } + int operator<(int i) { return code < i; } + int operator<=(int i) { return code <= i; } void encode(bufferlist &bl) const { __s32 newcode = hostos_to_ceph_errno(code); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 182a01bdb3133..a17d72372d58a 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -4797,7 +4797,7 @@ struct OSDOp { sobject_t soid; bufferlist indata, outdata; - int32_t rval; + errorcode32_t rval; OSDOp() : rval(0) { memset(&op, 0, sizeof(ceph_osd_op)); -- 2.39.5