diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2013-10-24 05:08:27 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2013-10-24 05:08:27 +0000 |
| commit | 5e98748fe88133419e681e9246fcaa169d8cc93d (patch) | |
| tree | e422e2e1ca42b1682163c07c33a68942bb45db6a /qpid/cpp | |
| parent | e8ab248b6ff6277b010646c326c786442646b231 (diff) | |
| download | qpid-python-5e98748fe88133419e681e9246fcaa169d8cc93d.tar.gz | |
QPID-4984: Fix compiler warnings caused by questionable programming practices
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1535277 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp | 13 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp | 8 |
2 files changed, 11 insertions, 10 deletions
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp index c78028362a..c61c8fe40b 100644 --- a/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp +++ b/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp @@ -248,10 +248,11 @@ bool EmptyFilePool::validateEmptyFile(const std::string& emptyFileName) const { } // Check file header - const bool jrnlMagicError = ((::file_hdr_t*)buff)->_rhdr._magic != QLS_FILE_MAGIC; - const bool jrnlVersionError = ((::file_hdr_t*)buff)->_rhdr._version != QLS_JRNL_VERSION; - const bool jrnlPartitionError = ((::file_hdr_t*)buff)->_efp_partition != partitionPtr_->getPartitionNumber(); - const bool jrnlFileSizeError = ((::file_hdr_t*)buff)->_file_size_kib != efpDataSize_kib_; + ::file_hdr_t* header(reinterpret_cast< ::file_hdr_t* >(buff)); + const bool jrnlMagicError = header->_rhdr._magic != QLS_FILE_MAGIC; + const bool jrnlVersionError = header->_rhdr._version != QLS_JRNL_VERSION; + const bool jrnlPartitionError = header->_efp_partition != partitionPtr_->getPartitionNumber(); + const bool jrnlFileSizeError = header->_file_size_kib != efpDataSize_kib_; if (jrnlMagicError || jrnlVersionError || jrnlPartitionError || jrnlFileSizeError) { oss << "ERROR: File " << emptyFileName << ": Invalid file header - mismatched header fields: " << @@ -265,8 +266,8 @@ bool EmptyFilePool::validateEmptyFile(const std::string& emptyFileName) const { } // Check file header is reset - if (!::is_file_hdr_reset((::file_hdr_t*)buff)) { - ::file_hdr_reset((::file_hdr_t*)buff); + if (!::is_file_hdr_reset(header)) { + ::file_hdr_reset(header); ::memset(buff + sizeof(::file_hdr_t), 0, MAX_FILE_HDR_LEN - sizeof(::file_hdr_t)); // set rest of buffer to 0 fs.seekp(0, std::fstream::beg); fs.write(buff, buffsize); diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp index 1370949908..3dc11ec27c 100644 --- a/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp +++ b/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp @@ -597,12 +597,12 @@ void RecoveryManager::readJournalData(char* target, getNextFile(false); } bool readFitsInFile = inFileStream_.tellg() + readSize <= fileSize_kib_ * 1024; - std::streamoff readSize = readFitsInFile ? readSize : (fileSize_kib_ * 1024) - inFileStream_.tellg(); - inFileStream_.read(target + bytesRead, readSize); - if (inFileStream_.gcount() != readSize) { + std::streamoff actualReadSize = readFitsInFile ? readSize : (fileSize_kib_ * 1024) - inFileStream_.tellg(); + inFileStream_.read(target + bytesRead, actualReadSize); + if (inFileStream_.gcount() != actualReadSize) { throw jexception(); // TODO - proper exception } - bytesRead += readSize; + bytesRead += actualReadSize; } } |
