From: Danny Al-Gaaf Date: Tue, 28 May 2013 12:41:30 +0000 (+0200) Subject: bench/dumb_backend.cc: check return value of lseek() X-Git-Tag: v0.65~168^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db2fbb1d61299a9de2e2c9df5d6a3f5727172009;p=ceph.git bench/dumb_backend.cc: check return value of lseek() CID 743395 (#1 of 1): Unchecked return value from library (CHECKED_RETURN) check_return: Calling function "lseek(fd, offset, 0)" without checking return value. This library function may fail and return an error code. unchecked_value: No check of the return value of "lseek(fd, offset, 0)". Signed-off-by: Danny Al-Gaaf --- diff --git a/src/test/bench/dumb_backend.cc b/src/test/bench/dumb_backend.cc index 170fee7fab6a..c36dce392da6 100644 --- a/src/test/bench/dumb_backend.cc +++ b/src/test/bench/dumb_backend.cc @@ -22,7 +22,14 @@ void DumbBackend::_write( std::cout << full_path << ": errno is " << errno << std::endl; assert(0); } - ::lseek(fd, offset, SEEK_SET); + + int r = ::lseek(fd, offset, SEEK_SET); + if (r < 0) { + r = errno; + std::cout << "lseek failed, errno is: " << r << std::endl; + ::close(fd); + return; + } bl.write_fd(fd); on_applied->complete(0); if (do_fsync) @@ -31,7 +38,7 @@ void DumbBackend::_write( ::sync_file_range(fd, offset, bl.length(), SYNC_FILE_RANGE_WAIT_AFTER); if (do_fadvise) { - int fa_r = posix_fadvise(fd, offset, bl.length(), POSIX_FADV_DONTNEED); + int fa_r = ::posix_fadvise(fd, offset, bl.length(), POSIX_FADV_DONTNEED); if (fa_r) { std::cout << "posix_fadvise failed, errno is: " << fa_r << std::endl; } @@ -58,6 +65,8 @@ void DumbBackend::read( int r = ::lseek(fd, offset, SEEK_SET); if (r < 0) { + r = errno; + std::cout << "lseek failed, errno is: " << r << std::endl; ::close(fd); return; }