From f410f8578eea403d0ca657e46ec7659cd0f805e7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Nov 2007 14:34:36 -0500 Subject: [PATCH] COMP: Fix warnings on 64-bit Mac OS X build. Patch from issue #3697. --- Source/CPack/cmCPackDebGenerator.cxx | 10 +++++----- Source/CPack/cmCPackNSISGenerator.cxx | 4 ++-- Source/CPack/cmCPackPackageMakerGenerator.cxx | 4 ++-- Source/CPack/cmCPackPackageMakerGenerator.h | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 6 +++--- Source/CTest/cmCTestSubmitHandler.cxx | 10 +++++++++- Source/cmake.cxx | 4 ++-- Source/kwsys/SystemTools.cxx | 7 +++---- Utilities/cmcurl/ftp.c | 5 +++-- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 75bf36fec..0c9eab696 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -338,7 +338,7 @@ static int copy_ar(CF *cfp, off_t size) { static char pad = '\n'; off_t sz = size; - int nr, nw; + size_t nr, nw; char buf[8*1024]; if (sz == 0) @@ -347,11 +347,11 @@ static int copy_ar(CF *cfp, off_t size) FILE* from = cfp->rFile; FILE* to = cfp->wFile; while (sz && - (nr = fread(buf, 1, sz < off_t(sizeof(buf)) ? sz : sizeof(buf), from )) + (nr = fread(buf, 1, sz < static_cast(sizeof(buf)) ? static_cast(sz) : sizeof(buf), from )) > 0) { sz -= nr; - for (int off = 0; off < nr; nr -= off, off += nw) - if ((nw = fwrite(buf + off, 1, nr, to)) < 0) + for (size_t off = 0; off < nr; nr -= off, off += nw) + if ((nw = fwrite(buf + off, 1, nr, to)) < nr) return -1; } if (sz) @@ -424,7 +424,7 @@ static int ar_append(const char* archive,const std::vector& files) FILE* aFile = fopen(archive, "wb+"); if (aFile!=NULL) { fwrite(ARMAG, SARMAG, 1, aFile); - if (fseek(aFile, (off_t)0, SEEK_END) != (off_t)-1) { + if (fseek(aFile, 0, SEEK_END) != -1) { CF cf; struct stat sb; /* Read from disk, write to an archive; pad on write. */ diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 8fa115224..953b36719 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -216,8 +216,8 @@ int cmCPackNSISGenerator::InitializeInternal() << "Please check " << tmpFile.c_str() << " for errors" << std::endl); return 0; } - float nsisVersion = atof(versionRex.match(1).c_str()); - float minNSISVersion = 2.09; + double nsisVersion = atof(versionRex.match(1).c_str()); + double minNSISVersion = 2.09; cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " << nsisVersion << std::endl); if ( nsisVersion < minNSISVersion ) diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 79dac067e..47078a79d 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -30,7 +30,7 @@ //---------------------------------------------------------------------- cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator() { - this->PackageMakerVersion = 0; + this->PackageMakerVersion = 0.0; } //---------------------------------------------------------------------- @@ -196,7 +196,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal() return 0; } this->PackageMakerVersion = atof(rexVersion.match(1).c_str()); - if ( this->PackageMakerVersion < 1 ) + if ( this->PackageMakerVersion < 1.0 ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher" << std::endl); diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 21cb4fca2..ee6f30283 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -48,7 +48,7 @@ protected: bool CopyCreateResourceFile(const char* name); bool CopyResourcePlistFile(const char* name); - float PackageMakerVersion; + double PackageMakerVersion; }; #endif diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 1f2739488..0606cd920 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1501,15 +1501,15 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( float cper = percentBranch + percentFunction; if(totalBranches > 0) { - cper /= 2.0; + cper /= 2.0f; } percent_coverage += cper; float cmet = percentFunction + percentBranch; if(totalBranches > 0) { - cmet /= 2.0; + cmet /= 2.0f; } - cmet /= 100.0; + cmet /= 100.0f; // Hack for conversion of function to loc assume a function // has 100 lines of code functionsCalled *=100; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 05a8e5a86..8e7919dfc 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -695,7 +695,15 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, return false; } - size_t fileSize = st.st_size; + // off_t can be bigger than size_t. fread takes size_t. + // make sure the file is not too big. + if (st.st_size > (size_t)-1) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, " File too big: " + << local_file.c_str() << std::endl); + return false; + } + size_t fileSize = static_cast(st.st_size); FILE* fp = fopen(local_file.c_str(), "rb"); if ( !fp ) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f8c2482fe..d85a69ac7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2484,8 +2484,8 @@ void cmake::TruncateOutputLog(const char* fname) cmSystemTools::RemoveFile(fullPath.c_str()); return; } - size_t fsize = st.st_size; - const size_t maxFileSize = 50 * 1024; + off_t fsize = st.st_size; + const off_t maxFileSize = 50 * 1024; if ( fsize < maxFileSize ) { //TODO: truncate file diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 759dc9f21..accfdd9c7 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1588,17 +1588,16 @@ bool SystemTools::FilesDiffer(const char* source, // Compare the files a block at a time. char source_buf[KWSYS_ST_BUFFER]; char dest_buf[KWSYS_ST_BUFFER]; - long nleft = statSource.st_size; + off_t nleft = statSource.st_size; while(nleft > 0) { // Read a block from each file. - long nnext = (nleft > KWSYS_ST_BUFFER)? KWSYS_ST_BUFFER : nleft; + kwsys_ios::streamsize nnext = (nleft > KWSYS_ST_BUFFER)? KWSYS_ST_BUFFER : static_cast(nleft); finSource.read(source_buf, nnext); finDestination.read(dest_buf, nnext); // If either failed to read assume they are different. - if(static_cast(finSource.gcount()) != nnext || - static_cast(finDestination.gcount()) != nnext) + if(finSource.gcount() != nnext || finDestination.gcount() != nnext) { return true; } diff --git a/Utilities/cmcurl/ftp.c b/Utilities/cmcurl/ftp.c index 378cd7f6d..883988938 100644 --- a/Utilities/cmcurl/ftp.c +++ b/Utilities/cmcurl/ftp.c @@ -3384,9 +3384,10 @@ CURLcode ftp_perform(struct connectdata *conn, } *connected = conn->bits.tcpconnect; - if(*dophase_done) + if(*dophase_done) { DEBUGF(infof(conn->data, "DO phase is complete\n")); - + } + return result; }