Skip to content

Commit

Permalink
First pass of warning cleanup
Browse files Browse the repository at this point in the history
This fixes g++ -Wall to compile warning free

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd committed Jul 23, 2019
1 parent b19c8d2 commit c1501ec
Show file tree
Hide file tree
Showing 44 changed files with 205 additions and 221 deletions.
29 changes: 7 additions & 22 deletions IlmBase/Half/half.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ class half
// Constructors
//-------------

half (); // no initialization
half () = default; // no initialization
half (float f);

// rule of 5
~half () = default;
half (const half &) = default;
half (half &&) noexcept = default;

//--------------------
// Conversion to float
Expand All @@ -118,7 +121,8 @@ class half
// Assignment
//-----------

half & operator = (half h);
half & operator = (const half &h) = default;
half & operator = (half &&h) noexcept = default;
half & operator = (float f);

half & operator += (half h);
Expand Down Expand Up @@ -417,17 +421,6 @@ HALF_EXPORT void printBits (char c[35], float f);
//---------------------------------------------------------------------------


//--------------------
// Simple constructors
//--------------------

inline
half::half ()
{
// no initialization
}


//----------------------------
// Half-from-float constructor
//----------------------------
Expand Down Expand Up @@ -575,14 +568,6 @@ half::operator - () const
}


inline half &
half::operator = (half h)
{
_h = h._h;
return *this;
}


inline half &
half::operator = (float f)
{
Expand Down
1 change: 0 additions & 1 deletion IlmBase/Half/halfFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ halfFunction<T>::halfFunction (Function f,
{
#ifndef ILMBASE_HAVE_LARGE_STACK
_lut = new T[1<<16];
memset (_lut, 0 , (1<<16) * sizeof(T));
#endif

for (int i = 0; i < (1 << 16); i++)
Expand Down
6 changes: 3 additions & 3 deletions IlmBase/ImathTest/testFrustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ testFrustum ()
(void)badFrustum.projectionMatrix();
assert (!"near == far didn't throw an exception");
}
catch (IEX_NAMESPACE::DivzeroExc)
catch (IEX_NAMESPACE::DivzeroExc &)
{
caught = true;
}
Expand All @@ -239,7 +239,7 @@ testFrustum ()
(void)badFrustum.projectionMatrix();
assert (!"left == right didn't throw an exception");
}
catch (IEX_NAMESPACE::DivzeroExc)
catch (IEX_NAMESPACE::DivzeroExc &)
{
caught = true;
}
Expand All @@ -253,7 +253,7 @@ testFrustum ()
(void)badFrustum.projectionMatrix();
assert (!"top == bottom didn't throw an exception");
}
catch (IEX_NAMESPACE::DivzeroExc)
catch (IEX_NAMESPACE::DivzeroExc &)
{
caught = true;
}
Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ readSampleCountForLineBlock(InputStreamMutex* streamData,



if(sampleCountTableDataSize>data->maxSampleCountTableSize)
if(sampleCountTableDataSize>static_cast<Int64>(data->maxSampleCountTableSize))
{
THROW (IEX_NAMESPACE::ArgExc, "Bad sampleCountTableDataSize read from chunk "<< lineBlockId << ": expected " << data->maxSampleCountTableSize << " or less, got "<< sampleCountTableDataSize);
}
Expand Down Expand Up @@ -1839,7 +1839,7 @@ readSampleCountForLineBlock(InputStreamMutex* streamData,
//


if (sampleCountTableDataSize < data->maxSampleCountTableSize)
if (sampleCountTableDataSize < Int64(data->maxSampleCountTableSize))
{
if(!data->sampleCountTableComp)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ writeLineOffsets (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const vector<Int6
{
Int64 pos = os.tellp();

if (pos == -1)
if (pos == Int64(-1))
IEX_NAMESPACE::throwErrnoExc ("Cannot determine current file position (%T).");

for (unsigned int i = 0; i < lineOffsets.size(); i++)
Expand Down
57 changes: 29 additions & 28 deletions OpenEXR/IlmImf/ImfDwaCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ struct DwaCompressor::Classifier
_suffix = std::string(suffix);
}

if (size < _suffix.length() + 1 + 2*Xdr::size<char>())
if (static_cast<size_t>(size) < _suffix.length() + 1 + 2*Xdr::size<char>())
throw IEX_NAMESPACE::InputExc("Error uncompressing DWA data"
" (truncated rule).");

Expand Down Expand Up @@ -700,7 +700,7 @@ DwaCompressor::LossyDctDecoderBase::~LossyDctDecoderBase () {}
void
DwaCompressor::LossyDctDecoderBase::execute ()
{
int numComp = _rowPtrs.size();
size_t numComp = _rowPtrs.size();
int lastNonZero = 0;
int numBlocksX = (int) ceil ((float)_width / 8.0f);
int numBlocksY = (int) ceil ((float)_height / 8.0f);
Expand Down Expand Up @@ -743,7 +743,7 @@ DwaCompressor::LossyDctDecoderBase::execute ()
rowBlock[0] = (unsigned short *)(rowBlockHandle + i);
}

for (int comp = 1; comp < numComp; ++comp)
for (size_t comp = 1; comp < numComp; ++comp)
rowBlock[comp] = rowBlock[comp - 1] + numBlocksX * 64;

//
Expand All @@ -754,7 +754,7 @@ DwaCompressor::LossyDctDecoderBase::execute ()

currDcComp[0] = (unsigned short *)_packedDc;

for (unsigned int comp = 1; comp < numComp; ++comp)
for (size_t comp = 1; comp < numComp; ++comp)
currDcComp[comp] = currDcComp[comp - 1] + numBlocksX * numBlocksY;

for (int blocky = 0; blocky < numBlocksY; ++blocky)
Expand Down Expand Up @@ -783,7 +783,7 @@ DwaCompressor::LossyDctDecoderBase::execute ()

bool blockIsConstant = true;

for (unsigned int comp = 0; comp < numComp; ++comp)
for (size_t comp = 0; comp < numComp; ++comp)
{

//
Expand Down Expand Up @@ -939,7 +939,7 @@ DwaCompressor::LossyDctDecoderBase::execute ()
// If the block has a constant value, just convert the first pixel.
//

for (unsigned int comp = 0; comp < numComp; ++comp)
for (size_t comp = 0; comp < numComp; ++comp)
{
if (!blockIsConstant)
{
Expand Down Expand Up @@ -995,7 +995,7 @@ DwaCompressor::LossyDctDecoderBase::execute ()
// * full 8-element wide blocks
//

for (int comp = 0; comp < numComp; ++comp)
for (size_t comp = 0; comp < numComp; ++comp)
{
//
// Test if we can use the fast path
Expand Down Expand Up @@ -1137,7 +1137,7 @@ DwaCompressor::LossyDctDecoderBase::execute ()
// Convert from HALF XDR back to FLOAT XDR.
//

for (unsigned int chan = 0; chan < numComp; ++chan)
for (size_t chan = 0; chan < numComp; ++chan)
{

if (_type[chan] != FLOAT)
Expand Down Expand Up @@ -2340,8 +2340,9 @@ DwaCompressor::uncompress
int minY = range.min.y;
int maxY = std::min (range.max.y, _max[1]);

int headerSize = NUM_SIZES_SINGLE*sizeof(Int64);
if (inSize < headerSize)
Int64 iSize = static_cast<Int64>( inSize );
Int64 headerSize = NUM_SIZES_SINGLE*sizeof(Int64);
if (iSize < headerSize)
{
throw IEX_NAMESPACE::InputExc("Error uncompressing DWA data"
"(truncated header).");
Expand Down Expand Up @@ -2387,11 +2388,11 @@ DwaCompressor::uncompress
const char *dataPtr = inPtr + NUM_SIZES_SINGLE * sizeof(Int64);

/* Both the sum and individual sizes are checked in case of overflow. */
if (inSize < (headerSize + compressedSize) ||
inSize < unknownCompressedSize ||
inSize < acCompressedSize ||
inSize < dcCompressedSize ||
inSize < rleCompressedSize)
if (iSize < (headerSize + compressedSize) ||
iSize < unknownCompressedSize ||
iSize < acCompressedSize ||
iSize < dcCompressedSize ||
iSize < rleCompressedSize)
{
throw IEX_NAMESPACE::InputExc("Error uncompressing DWA data"
"(truncated file).");
Expand Down Expand Up @@ -2423,7 +2424,7 @@ DwaCompressor::uncompress
" (corrupt header file).");

headerSize += ruleSize;
if (inSize < headerSize + compressedSize)
if (iSize < headerSize + compressedSize)
throw IEX_NAMESPACE::InputExc("Error uncompressing DWA data"
" (truncated file).");

Expand All @@ -2446,9 +2447,9 @@ DwaCompressor::uncompress
// Allocate _outBuffer, if we haven't done so already
//

if (_maxScanLineSize * numScanLines() > _outBufferSize)
if (static_cast<size_t>(_maxScanLineSize * numScanLines()) > _outBufferSize)
{
_outBufferSize = _maxScanLineSize * numScanLines();
_outBufferSize = static_cast<size_t>(_maxScanLineSize * numScanLines());
if (_outBuffer != 0)
delete[] _outBuffer;
_outBuffer = new char[_maxScanLineSize * numScanLines()];
Expand Down Expand Up @@ -2594,9 +2595,9 @@ DwaCompressor::uncompress
"(corrupt header).");
}

if (_zip->uncompress
(compressedDcBuf, (int)dcCompressedSize, _packedDcBuffer)
!= (int)totalDcUncompressedCount * sizeof (unsigned short))
if (static_cast<Int64>(_zip->uncompress
(compressedDcBuf, (int)dcCompressedSize, _packedDcBuffer))
!= totalDcUncompressedCount * sizeof (unsigned short))
{
throw IEX_NAMESPACE::BaseExc("DC data corrupt.");
}
Expand Down Expand Up @@ -2630,11 +2631,11 @@ DwaCompressor::uncompress
if (dstLen != rleUncompressedSize)
throw IEX_NAMESPACE::BaseExc("RLE data corrupted");

if (rleUncompress
if (static_cast<Int64>(rleUncompress
((int)rleUncompressedSize,
(int)rleRawSize,
(signed char *)_rleBuffer,
_planarUncBuffer[RLE]) != rleRawSize)
_planarUncBuffer[RLE])) != rleRawSize)
{
throw IEX_NAMESPACE::BaseExc("RLE data corrupted");
}
Expand Down Expand Up @@ -2998,7 +2999,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)

if (_zip == 0)
_zip = new Zip (maxLossyDctDcSize * numLossyDctChans);
else if (_zip->maxRawSize() < maxLossyDctDcSize * numLossyDctChans)
else if (_zip->maxRawSize() < static_cast<size_t>(maxLossyDctDcSize * numLossyDctChans))
{
delete _zip;
_zip = new Zip (maxLossyDctDcSize * numLossyDctChans);
Expand Down Expand Up @@ -3035,7 +3036,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// to Huffman encoding
//

if (maxLossyDctAcSize * numLossyDctChans > _packedAcBufferSize)
if (static_cast<size_t>(maxLossyDctAcSize * numLossyDctChans) > _packedAcBufferSize)
{
_packedAcBufferSize = maxLossyDctAcSize * numLossyDctChans;
if (_packedAcBuffer != 0)
Expand All @@ -3047,15 +3048,15 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// _packedDcBuffer holds one quantized DCT coef per 8x8 block
//

if (maxLossyDctDcSize * numLossyDctChans > _packedDcBufferSize)
if (static_cast<size_t>(maxLossyDctDcSize * numLossyDctChans) > _packedDcBufferSize)
{
_packedDcBufferSize = maxLossyDctDcSize * numLossyDctChans;
if (_packedDcBuffer != 0)
delete[] _packedDcBuffer;
_packedDcBuffer = new char[_packedDcBufferSize];
}

if (rleBufferSize > _rleBufferSize)
if (static_cast<size_t>(rleBufferSize) > _rleBufferSize)
{
_rleBufferSize = rleBufferSize;
if (_rleBuffer != 0)
Expand Down Expand Up @@ -3116,7 +3117,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)

for (int i = 0; i < NUM_COMPRESSOR_SCHEMES; ++i)
{
if (planarUncBufferSize[i] > _planarUncBufferSize[i])
if (static_cast<size_t>(planarUncBufferSize[i]) > _planarUncBufferSize[i])
{
_planarUncBufferSize[i] = planarUncBufferSize[i];
if (_planarUncBuffer[i] != 0)
Expand Down
12 changes: 6 additions & 6 deletions OpenEXR/IlmImf/ImfFastHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ FastHufDecoder::FastHufDecoder
const int LONG_ZEROCODE_RUN = 63;
const int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN;

for (Int64 symbol = minSymbol; symbol <= maxSymbol; symbol++)
for (Int64 symbol = static_cast<Int64>(minSymbol); symbol <= static_cast<Int64>(maxSymbol); symbol++)
{
if (currByte - table > numBytes)
{
Expand Down Expand Up @@ -153,7 +153,7 @@ FastHufDecoder::FastHufDecoder
int runLen = readBits (8, currBits, currBitCount, currByte) +
SHORTEST_LONG_RUN;

if (symbol + runLen > maxSymbol + 1)
if (symbol + runLen > Int64(maxSymbol + 1))
{
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table "
"(Run beyond end of table).");
Expand All @@ -166,7 +166,7 @@ FastHufDecoder::FastHufDecoder
{
int runLen = codeLen - SHORT_ZEROCODE_RUN + 2;

if (symbol + runLen > maxSymbol + 1)
if (symbol + runLen > static_cast<Int64>(maxSymbol + 1))
{
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table "
"(Run beyond end of table).");
Expand Down Expand Up @@ -255,7 +255,7 @@ FastHufDecoder::FastHufDecoder
int codeLen = *i & 63;
int symbol = *i >> 6;

if (mapping[codeLen] >= _numSymbols)
if (mapping[codeLen] >= Int64(_numSymbols))
throw IEX_NAMESPACE::InputExc ("Huffman decode error "
"(Invalid symbol in header).");

Expand Down Expand Up @@ -395,7 +395,7 @@ FastHufDecoder::buildTables (Int64 *base, Int64 *offset)
_tableCodeLen[i] = codeLen;

Int64 id = _ljOffset[codeLen] + (value >> (64 - codeLen));
if (id < _numSymbols)
if (id < Int64(_numSymbols))
{
_tableSymbol[i] = _idToSymbol[id];
}
Expand Down Expand Up @@ -667,7 +667,7 @@ FastHufDecoder::decode
}

Int64 id = _ljOffset[codeLen] + (buffer >> (64 - codeLen));
if (id < _numSymbols)
if (id < Int64(_numSymbols))
{
symbol = _idToSymbol[id];
}
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ Header::sanityCheck (bool isTiled, bool isMultipartFile) const
// (only reachable for unknown types or damaged files: will have thrown earlier
// for regular image types)
if( maxImageHeight>0 && maxImageWidth>0 &&
hasChunkCount() && chunkCount()>Int64(maxImageWidth)*Int64(maxImageHeight))
hasChunkCount() && static_cast<Int64>(chunkCount())>Int64(maxImageWidth)*Int64(maxImageHeight))
{
THROW (IEX_NAMESPACE::ArgExc, "chunkCount exceeds maximum area of "
<< Int64(maxImageWidth)*Int64(maxImageHeight) << " pixels." );
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfMultiPartOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ MultiPartOutputFile::Data::writeChunkTableOffsets (vector<OutputPartData*> &part

Int64 pos = os->tellp();

if (pos == -1)
if (pos == Int64(-1))
IEX_NAMESPACE::throwErrnoExc ("Cannot determine current file position (%T).");

parts[i]->chunkOffsetTablePosition = os->tellp();
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ writeLineOffsets (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const vector<Int6
{
Int64 pos = os.tellp();

if (pos == -1)
if (pos == Int64(-1))
IEX_NAMESPACE::throwErrnoExc ("Cannot determine current file position (%T).");

for (unsigned int i = 0; i < lineOffsets.size(); i++)
Expand Down
Loading

0 comments on commit c1501ec

Please sign in to comment.