[Box Backup] PATCH: Fixes for linux/amd64
Martin Ebourne
boxbackup@fluffy.co.uk
Mon, 13 Sep 2004 21:20:17 +0100
--=-gBUE13NuUlagTewPSvYO
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi,
This patch fixes a bunch of warnings when compiling on Fedora Core 2,
AMD64.
Two of these warnings were definite bugs - the SplitString one caused an
infinite loop and subsequent out of memory. Unfortunately a lot of these
had to be fixed with casts.
I've tested the patch on Fedora Core 2/i386 and they still seem ok.
I didn't fix a whole load of warnings about mismatch between printf's
%llx and the actual type, I guess that would probably result in warnings
for 32 bit archs.
Cheers,
Martin.
--=-gBUE13NuUlagTewPSvYO
Content-Description:
Content-Disposition: inline; filename=boxbackup-0.07-x86_64.patch
Content-Type: text/x-patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
diff -ur boxbackup-0.07.orig/lib/backupclient/BackupStoreFileDiff.cpp boxbackup-0.07/lib/backupclient/BackupStoreFileDiff.cpp
--- boxbackup-0.07.orig/lib/backupclient/BackupStoreFileDiff.cpp 2004-09-09 20:49:19.869539201 +0100
+++ boxbackup-0.07/lib/backupclient/BackupStoreFileDiff.cpp 2004-09-09 21:19:03.188201856 +0100
@@ -147,7 +147,7 @@
int64_t blockHeaderPosFromEnd = ((numBlocks * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader));
// Sanity check
- if(blockHeaderPosFromEnd > fileSize - sizeof(file_StreamFormat))
+ if(blockHeaderPosFromEnd > static_cast<int64_t>(fileSize - sizeof(file_StreamFormat)))
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
@@ -627,7 +627,7 @@
break;
}
- if(rFoundBlocks.size() > (NumBlocks * BACKUP_FILE_DIFF_MAX_BLOCK_FIND_MULTIPLE)
+ if(static_cast<int64_t>(rFoundBlocks.size()) > (NumBlocks * BACKUP_FILE_DIFF_MAX_BLOCK_FIND_MULTIPLE)
|| sDiffTimedOut)
{
abortSearch = true;
diff -ur boxbackup-0.07.orig/lib/backupclient/BackupStoreFileEncodeStream.cpp boxbackup-0.07/lib/backupclient/BackupStoreFileEncodeStream.cpp
--- boxbackup-0.07.orig/lib/backupclient/BackupStoreFileEncodeStream.cpp 2004-09-09 20:49:19.871538971 +0100
+++ boxbackup-0.07/lib/backupclient/BackupStoreFileEncodeStream.cpp 2004-09-09 21:24:31.767368140 +0100
@@ -413,14 +413,14 @@
++mInstructionNumber;
// Skip instructions which don't contain any data
- while(mInstructionNumber < mpRecipe->size()
+ while(mInstructionNumber < static_cast<int64_t>(mpRecipe->size())
&& (*mpRecipe)[mInstructionNumber].mSpaceBefore == 0)
{
SkipPreviousBlocksInInstruction();
++mInstructionNumber;
}
- if(mInstructionNumber >= mpRecipe->size())
+ if(mInstructionNumber >= static_cast<int64_t>(mpRecipe->size()))
{
// End of blocks, go to next phase
++mStatus;
diff -ur boxbackup-0.07.orig/lib/backupstore/BackupStoreInfo.cpp boxbackup-0.07/lib/backupstore/BackupStoreInfo.cpp
--- boxbackup-0.07.orig/lib/backupstore/BackupStoreInfo.cpp 2004-09-09 20:49:19.945530451 +0100
+++ boxbackup-0.07/lib/backupstore/BackupStoreInfo.cpp 2004-09-09 21:33:06.883055976 +0100
@@ -258,7 +258,7 @@
}
// Final check
- if(info->mDeletedDirectories.size() != numDelObj)
+ if(static_cast<int64_t>(info->mDeletedDirectories.size()) != numDelObj)
{
THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad)
}
diff -ur boxbackup-0.07.orig/lib/common/ConversionString.cpp boxbackup-0.07/lib/common/ConversionString.cpp
--- boxbackup-0.07.orig/lib/common/ConversionString.cpp 2004-09-09 20:49:19.908534711 +0100
+++ boxbackup-0.07/lib/common/ConversionString.cpp 2004-09-09 21:39:12.690935619 +0100
@@ -85,7 +85,7 @@
// Convert.
char *numEnd = 0;
- int32_t r = ::strtol(pString, &numEnd, 0);
+ long r = ::strtol(pString, &numEnd, 0);
// Check that all the characters were used
if(*numEnd != '\0')
diff -ur boxbackup-0.07.orig/lib/common/Utils.cpp boxbackup-0.07/lib/common/Utils.cpp
--- boxbackup-0.07.orig/lib/common/Utils.cpp 2004-09-09 20:49:19.910534481 +0100
+++ boxbackup-0.07/lib/common/Utils.cpp 2004-09-09 21:13:29.612610879 +0100
@@ -73,8 +73,8 @@
void SplitString(const std::string &String, char SplitOn, std::vector<std::string> &rOutput)
{
// Split it up.
- unsigned int b = 0;
- unsigned int e = 0;
+ std::string::size_type b = 0;
+ std::string::size_type e = 0;
while(e = String.find_first_of(SplitOn, b), e != String.npos)
{
// Get this string
diff -ur boxbackup-0.07.orig/lib/raidfile/RaidFileRead.cpp boxbackup-0.07/lib/raidfile/RaidFileRead.cpp
--- boxbackup-0.07.orig/lib/raidfile/RaidFileRead.cpp 2004-09-09 20:49:19.947530221 +0100
+++ boxbackup-0.07/lib/raidfile/RaidFileRead.cpp 2004-09-09 21:32:05.600112302 +0100
@@ -1252,7 +1252,7 @@
pos_type paritySize = st.st_size;
FileSizeType parityLastData = 0;
bool parityIntegralPlusOffT = ((paritySize % blockSize) == sizeof(FileSizeType));
- if(paritySize >= sizeof(parityLastData) && (parityIntegralPlusOffT || stripe1 != -1))
+ if(paritySize >= static_cast<pos_type>(sizeof(parityLastData)) && (parityIntegralPlusOffT || stripe1 != -1))
{
// Seek to near the end
ASSERT(sizeof(FileSizeType) == 8); // compiler bug (I think) prevents from using 0 - sizeof(FileSizeType)...
@@ -1367,7 +1367,7 @@
// No. Working out the size is easy.
length = stripe2Size + (((stripe2Size / blockSize)+1) * blockSize);
// Got last block size in there?
- if((stripe2Size % blockSize) <= (blockSize - sizeof(pos_type)))
+ if((stripe2Size % blockSize) <= static_cast<pos_type>((blockSize - sizeof(pos_type))))
{
// Yes...
lastBlockHasSize = true;
--=-gBUE13NuUlagTewPSvYO--