Skip to content

Commit

Permalink
hypertable/CephBroker.cc: use int64_t instead of uint64_t
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dalgaaf committed Apr 26, 2018
1 parent c2a4af6 commit 7a17f59
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/client/hypertable/CephBroker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -221,15 +221,15 @@ 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,
uint32_t amount, const void *data, bool sync)
{
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;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 7a17f59

Please sign in to comment.