From 7a17f5938bc21ffb7eebccbf082cd439e65c4dad Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 26 Apr 2018 10:12:00 +0200 Subject: [PATCH] hypertable/CephBroker.cc: use int64_t instead of uint64_t The usage of uint64_t to get the return value of ceph_lseek() will lead to loss of the error code returned from the function. This will break error case detection. Use a signed variable and cast before offset returned instead. Fix for: [src/client/hypertable/CephBroker.cc:209]: (style) Checking if unsigned variable 'offset=ceph_lseek(cmount,fdata->fd,0,SEEK_CUR)' is less than zero. [src/client/hypertable/CephBroker.cc:244]: (style) Checking if unsigned variable 'offset=(uint64_t)ceph_lseek(cmount,fdata->fd,0,SEEK_CUR)' is less than zero. Signed-off-by: Danny Al-Gaaf --- src/client/hypertable/CephBroker.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/hypertable/CephBroker.cc b/src/client/hypertable/CephBroker.cc index 91578a17236..4e6ee504ea3 100644 --- a/src/client/hypertable/CephBroker.cc +++ b/src/client/hypertable/CephBroker.cc @@ -193,7 +193,7 @@ void CephBroker::close(ResponseCallback *cb, uint32_t fd) { void CephBroker::read(ResponseCallbackRead *cb, uint32_t fd, uint32_t amount) { OpenFileDataCephPtr fdata; ssize_t nread; - uint64_t offset; + int64_t offset; StaticBuffer buf(new uint8_t [amount], amount); HT_DEBUGF("read fd=%" PRIu32 " amount = %d", fd, amount); @@ -207,7 +207,7 @@ void CephBroker::read(ResponseCallbackRead *cb, uint32_t fd, uint32_t amount) { } if ((offset = ceph_lseek(cmount, fdata->fd, 0, SEEK_CUR)) < 0) { - std::string errs(cpp_strerror((int)-offset)); + std::string errs(cpp_strerror(offset)); HT_ERRORF("lseek failed: fd=%" PRIu32 " ceph_fd=%d offset=0 SEEK_CUR - %s", fd, fdata->fd, errs.c_str()); report_error(cb, offset); @@ -221,7 +221,7 @@ void CephBroker::read(ResponseCallbackRead *cb, uint32_t fd, uint32_t amount) { } buf.size = nread; - cb->response(offset, buf); + cb->response((uint64_t)offset, buf); } void CephBroker::append(ResponseCallbackAppend *cb, uint32_t fd, @@ -229,7 +229,7 @@ void CephBroker::append(ResponseCallbackAppend *cb, uint32_t fd, { OpenFileDataCephPtr fdata; ssize_t nwritten; - uint64_t offset; + int64_t offset; HT_DEBUG_OUT << "append fd="<< fd <<" amount="<< amount <<" data='" << format_bytes(20, data, amount) <<" sync="<< sync << HT_END; @@ -241,8 +241,8 @@ void CephBroker::append(ResponseCallbackAppend *cb, uint32_t fd, return; } - if ((offset = (uint64_t)ceph_lseek(cmount, fdata->fd, 0, SEEK_CUR)) < 0) { - std::string errs(cpp_strerror((int)-offset)); + if ((offset = ceph_lseek(cmount, fdata->fd, 0, SEEK_CUR)) < 0) { + std::string errs(cpp_strerror(offset)); HT_ERRORF("lseek failed: fd=%" PRIu32 " ceph_fd=%d offset=0 SEEK_CUR - %s", fd, fdata->fd, errs.c_str()); report_error(cb, offset); @@ -265,7 +265,7 @@ void CephBroker::append(ResponseCallbackAppend *cb, uint32_t fd, return; } - cb->response(offset, nwritten); + cb->response((uint64_t)offset, nwritten); } void CephBroker::seek(ResponseCallback *cb, uint32_t fd, uint64_t offset) { -- 2.39.5