From 8ec08c2dae96905c796cb656c47689b21974b76c Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 25 Sep 2012 14:19:49 -0700 Subject: [PATCH] FileJournal: check return value of lseek in write_fd CID 716859: Other violation (CHECKED_RETURN)At (1): Calling function "lseek64(this->fd, pos, 0)" without checking return value. This library function may fail and return an error code. Signed-off-by: Samuel Just --- src/os/FileJournal.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index eec5c9d320c2c..d1c92dc0937a2 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -946,8 +946,13 @@ int FileJournal::write_bl(off64_t& pos, bufferlist& bl) { align_bl(pos, bl); - ::lseek64(fd, pos, SEEK_SET); - int ret = bl.write_fd(fd); + int ret = ::lseek64(fd, pos, SEEK_SET); + if (ret) { + ret = -errno; + derr << "FileJournal::write_bl : lseek64 failed " << cpp_strerror(ret) << dendl; + return ret; + } + ret = bl.write_fd(fd); if (ret) { derr << "FileJournal::write_bl : write_fd failed: " << cpp_strerror(ret) << dendl; return ret; -- 2.39.5