You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2013/10/24 07:08:27 UTC

svn commit: r1535277 - in /qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl: EmptyFilePool.cpp RecoveryManager.cpp

Author: astitcher
Date: Thu Oct 24 05:08:27 2013
New Revision: 1535277

URL: http://svn.apache.org/r1535277
Log:
QPID-4984: Fix compiler warnings caused by questionable programming practices

Modified:
    qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp
    qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp?rev=1535277&r1=1535276&r2=1535277&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/EmptyFilePool.cpp Thu Oct 24 05:08:27 2013
@@ -248,10 +248,11 @@ bool EmptyFilePool::validateEmptyFile(co
     }
 
     // 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(co
     }
 
     // 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);

Modified: qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp?rev=1535277&r1=1535276&r2=1535277&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/linearstore/jrnl/RecoveryManager.cpp Thu Oct 24 05:08:27 2013
@@ -597,12 +597,12 @@ void RecoveryManager::readJournalData(ch
             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;
     }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org