From fa5d5e865c6e022e69d19aff780fdf6c6852073b Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 28 Jan 2013 20:20:52 -0500 Subject: [PATCH] Fix some more compiler warnings. This time some were actually very useful\! --- BPTCEncoder/src/BC7Compressor.cpp | 4 ++-- Core/src/Image.cpp | 8 ++++---- Core/src/WorkerQueue.cpp | 2 +- IO/src/ImageFile.cpp | 6 ++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/BPTCEncoder/src/BC7Compressor.cpp b/BPTCEncoder/src/BC7Compressor.cpp index 161d91e..bec62f3 100755 --- a/BPTCEncoder/src/BC7Compressor.cpp +++ b/BPTCEncoder/src/BC7Compressor.cpp @@ -730,7 +730,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto } RGBACluster rgbCluster; - float alphaVals[kMaxNumDataPoints]; + float alphaVals[kMaxNumDataPoints] = {0}; float alphaMin = FLT_MAX, alphaMax = -FLT_MAX; for(uint32 i = 0; i < cluster.GetNumPoints(); i++) { @@ -1013,7 +1013,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto assert(pts[nBuckets - 1] == p2); // Do k-means clustering... - uint32 bucketIdx[kMaxNumDataPoints]; + uint32 bucketIdx[kMaxNumDataPoints] = {0}; bool fixed = false; while(!fixed) { diff --git a/Core/src/Image.cpp b/Core/src/Image.cpp index 6c03f7b..9fbb3b0 100644 --- a/Core/src/Image.cpp +++ b/Core/src/Image.cpp @@ -93,10 +93,10 @@ CompressedImage *Image::Compress(const SCompressionSettings &settings) const { // Allocate data based on the compression method int cmpDataSz = 0; switch(settings.format) { - default: assert(!"Not implemented!"); - case eCompressionFormat_DXT1: cmpDataSz = dataSz / 8; - case eCompressionFormat_DXT5: cmpDataSz = dataSz / 4; - case eCompressionFormat_BPTC: cmpDataSz = dataSz / 4; + default: assert(!"Not implemented!"); // Fall Through V + case eCompressionFormat_DXT1: cmpDataSz = dataSz / 8; break; + case eCompressionFormat_DXT5: cmpDataSz = dataSz / 4; break; + case eCompressionFormat_BPTC: cmpDataSz = dataSz / 4; break; } unsigned char *cmpData = new unsigned char[cmpDataSz]; diff --git a/Core/src/WorkerQueue.cpp b/Core/src/WorkerQueue.cpp index 62a802c..2a0bfd3 100644 --- a/Core/src/WorkerQueue.cpp +++ b/Core/src/WorkerQueue.cpp @@ -227,7 +227,7 @@ void WorkerQueue::NotifyWorkerFinished() { } WorkerThread::EAction WorkerQueue::AcceptThreadData(uint32 threadIdx) { - if(threadIdx < 0 || threadIdx >= m_ActiveThreads) { + if(threadIdx >= m_ActiveThreads) { return WorkerThread::eAction_Quit; } diff --git a/IO/src/ImageFile.cpp b/IO/src/ImageFile.cpp index 9189e67..1f14771 100644 --- a/IO/src/ImageFile.cpp +++ b/IO/src/ImageFile.cpp @@ -206,10 +206,8 @@ EImageFileFormat ImageFile::DetectFileFormat(const CHAR *filename) { size_t dotPos = len - 1; - while(dotPos >= 0 && filename[dotPos--] != '.'); - - if(dotPos < 0) { - // !FIXME! Report Error..... + while((dotPos >= len)? false : filename[dotPos--] != '.'); + if (dotPos >= len) { return kNumImageFileFormats; }