Skip to content

Commit

Permalink
Convert constructor casts to static_cast, remove dead code
Browse files Browse the repository at this point in the history
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd committed Jul 23, 2019
1 parent 6d4e118 commit 5cbf3cb
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 53 deletions.
3 changes: 2 additions & 1 deletion IlmBase/Imath/ImathFrustum.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ void Frustum<T>::modifyNearAndFar(T n, T f)
Line3<T> upperRight( Vec3<T>(0,0,0), Vec3<T>(_right,_top,-_nearPlane) );
Plane3<T> nearPlane( Vec3<T>(0,0,-1), n );

Vec3<T> ll = Vec3<T> (0, 0, 0), ur = Vec3<T> (0, 0, 0);
Vec3<T> ll = Vec3<T> (0, 0, 0);
Vec3<T> ur = Vec3<T> (0, 0, 0);
nearPlane.intersect(lowerLeft,ll);
nearPlane.intersect(upperRight,ur);

Expand Down
6 changes: 5 additions & 1 deletion IlmBase/ImathTest/testExtractSHRT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ testMatrix (const M33f M)
V2f s(0.f), t(0.f);
float h, r= 0.f;

extractSHRT (M, s, h, r, t, true);
if (!extractSHRT (M, s, h, r, t, true))
{
cout << "Unable to extractSHRT" << std::endl;
assert(false);
}

M33f N;

Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ readSampleCountForLineBlock(InputStreamMutex* streamData,
//


if (sampleCountTableDataSize < Int64(data->maxSampleCountTableSize))
if (sampleCountTableDataSize < static_cast<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 == Int64(-1))
if (pos == static_cast<Int64>(-1))
IEX_NAMESPACE::throwErrnoExc ("Cannot determine current file position (%T).");

for (unsigned int i = 0; i < lineOffsets.size(); i++)
Expand Down
10 changes: 5 additions & 5 deletions OpenEXR/IlmImf/ImfFastHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ FastHufDecoder::FastHufDecoder
int runLen = readBits (8, currBits, currBitCount, currByte) +
SHORTEST_LONG_RUN;

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

}
else if (codeLen >= (Int64) SHORT_ZEROCODE_RUN)
else if (codeLen >= static_cast<Int64>(SHORT_ZEROCODE_RUN))
{
int runLen = codeLen - SHORT_ZEROCODE_RUN + 2;

Expand Down Expand Up @@ -255,7 +255,7 @@ FastHufDecoder::FastHufDecoder
int codeLen = *i & 63;
int symbol = *i >> 6;

if (mapping[codeLen] >= Int64(_numSymbols))
if (mapping[codeLen] >= static_cast<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 < Int64(_numSymbols))
if (id < static_cast<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 < Int64(_numSymbols))
if (id < static_cast<Int64>(_numSymbols))
{
symbol = _idToSymbol[id];
}
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfTileOffsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ TileOffsets::writeTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os) const

Int64 pos = os.tellp();

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

for (unsigned int l = 0; l < _offsets.size(); ++l)
Expand Down
5 changes: 0 additions & 5 deletions OpenEXR/IlmImfExamples/drawImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ zsp (Array2D<half> &gpx, Array2D<float> &zpx, int w, int h,
if (r >= 1)
continue;

//float a = 1;

//if (r * rc > rc - 1)
//a = rc - r * rc;

float zl = sqrt (1 - r * r);
float zp = zc - rc * zl;

Expand Down
26 changes: 13 additions & 13 deletions OpenEXR/IlmImfExamples/lowLevelIoExamples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ class C_OStream: public OStream
bool
C_IStream::read (char c[/*n*/], int n)
{
if (size_t(n) != fread (c, 1, n, _file))
if (n != static_cast<int>(fread (c, 1, n, _file)))
{
//
// fread() failed, but the return value does not distinguish
// between I/O errors and end of file, so we call ferror() to
// determine what happened.
//

if (ferror (_file))
IEX_NAMESPACE::throwErrnoExc();
else
throw IEX_NAMESPACE::InputExc ("Unexpected end of file.");
//
// fread() failed, but the return value does not distinguish
// between I/O errors and end of file, so we call ferror() to
// determine what happened.
//

if (ferror (_file))
IEX_NAMESPACE::throwErrnoExc();
else
throw IEX_NAMESPACE::InputExc ("Unexpected end of file.");
}

return feof (_file);
Expand Down Expand Up @@ -143,8 +143,8 @@ C_OStream::write (const char c[/*n*/], int n)
{
clearerr (_file);

if (size_t(n) != fwrite (c, 1, n, _file))
IEX_NAMESPACE::throwErrnoExc();
if (n != static_cast<int>(fwrite (c, 1, n, _file)))
IEX_NAMESPACE::throwErrnoExc();
}


Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfExamples/rgbaInterfaceExamples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ readRgba2 (const char fileName[])
Box2i dw = file.dataWindow();

int width = dw.max.x - dw.min.x + 1;
//int height = dw.max.y - dw.min.y + 1;

Array2D<Rgba> pixels (10, width);

while (dw.min.y <= dw.max.y)
Expand Down
4 changes: 0 additions & 4 deletions OpenEXR/IlmImfFuzzTest/testFuzzDeepScanLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ void readFile(const char filename[])
file.readPixelSampleCounts(dataWindow.min.y, dataWindow.max.y);
for (int i = 0; i < dataWindow.max.y - dataWindow.min.y + 1; i++)
{
//int y = i + dataWindow.min.y;

for (int j = 0; j < width; j++)
{
for (int k = 0; k < channelCount; k++)
Expand Down Expand Up @@ -342,8 +340,6 @@ void readFile(const char filename[])
inpart.readPixelSampleCounts(dataWindow.min.y, dataWindow.max.y);
for (int i = 0; i < dataWindow.max.y - dataWindow.min.y + 1; i++)
{
//int y = i + dataWindow.min.y;

for (int j = 0; j < width; j++)
{
for (int k = 0; k < channelCount; k++)
Expand Down
14 changes: 7 additions & 7 deletions OpenEXR/IlmImfTest/testBadTypeAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@ template<class T> void readTiledThing(T & input,bool test)
case ONE_LEVEL :
x_levels = 1;
y_levels = 1;
break;
break;
case MIPMAP_LEVELS :
x_levels = input.numXLevels();
y_levels = 1;
break;
case RIPMAP_LEVELS :
x_levels = input.numXLevels();
y_levels = input.numYLevels();
break;
case NUM_LEVELMODES:
default:
std::cerr << "Invalid tile mode " << int(t.mode) << std::endl;
break;
case NUM_LEVELMODES:
default:
std::cerr << "Invalid tile mode " << int(t.mode) << std::endl;
x_levels = y_levels = 0;
break;
break;
}

for(int x_level = 0 ; x_level < x_levels ; x_level++)
for(int x_level = 0 ; x_level < x_levels ; x_level++)
{
for(int y_level = 0 ; y_level < y_levels ;y_level++)
{
Expand Down
4 changes: 0 additions & 4 deletions OpenEXR/IlmImfTest/testCopyDeepScanLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ const int minX = 42;
const int minY = 51;
const Box2i dataWindow(V2i(minX, minY), V2i(minX + width - 1, minY + height - 1));
const Box2i displayWindow(V2i(0, 0), V2i(minX + width * 2, minY + height * 2));
//const char source_filename[] = IMF_TMP_DIR "imf_test_copy_deep_scanline_source.exr";
//const char copy_filename[] = IMF_TMP_DIR "imf_test_copy_deep_scanline_copy.exr";

vector<int> channelTypes;
Array2D<unsigned int> sampleCount;
Expand Down Expand Up @@ -306,8 +304,6 @@ void readFile (const std::string & copy_filename, int channelCount)
file.readPixelSampleCounts(dataWindow.min.y, dataWindow.max.y);
for (int i = 0; i < dataWindow.max.y - dataWindow.min.y + 1; i++)
{
//int y = i + dataWindow.min.y;

for (int j = 0; j < width; j++)
assert(localSampleCount[i][j] == sampleCount[i][j]);

Expand Down
2 changes: 0 additions & 2 deletions OpenEXR/IlmImfTest/testDeepScanLineMultipleRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@

namespace{

//const char source_filename[] = IMF_TMP_DIR "imf_test_multiple_read.exr";

using std::cout;
using std::endl;
using std::flush;
Expand Down
3 changes: 1 addition & 2 deletions OpenEXR/IlmImfTest/testMultiPartApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ generateRandomFile (int partCount, const std::string & fn)
{
int partNumber = taskList[i].partNumber;
int partType = partTypes[partNumber];
//int pixelType = pixelTypes[partNumber];
//int levelMode = levelModes[partNumber];

if (partType == 0)
{
OutputPart* part = (OutputPart*) parts[partNumber];
Expand Down
1 change: 0 additions & 1 deletion OpenEXR/IlmImfTest/testMultiPartSharedAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ testPixelAspectRatio (const vector<Header> & hs, const std::string & fn)
{
vector<Header> headers(hs);

//IMATH_NAMESPACE::Box2i newDisplayWindow = headers[0].displayWindow();
Header newHeader (headers[0].displayWindow().size().x+1,
headers[0].displayWindow().size().y+1,
headers[0].pixelAspectRatio() + 1.f);
Expand Down
2 changes: 0 additions & 2 deletions OpenEXR/IlmImfTest/testMultiPartThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ class WritingTask: public Task
{
int partNumber = data[i]->partNumber;
int partType = partTypes[partNumber];
//int pixelType = pixelTypes[partNumber];
//int levelMode = levelModes[partNumber];

if (partType == 0)
{
Expand Down
2 changes: 0 additions & 2 deletions OpenEXR/IlmImfTest/testOptimized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ readPixels (const char pFilename[], int pNbChannels, Array2D<half>& pPixels)
IMATH::Box2i lDataWindow = lFile.header().dataWindow();

int lWidth = lDataWindow.max.x - lDataWindow.min.x + 1;
//int lHeight = lDataWindow.max.y - lDataWindow.min.y + 1;

FrameBuffer lInputFrameBuffer;

Expand Down Expand Up @@ -383,7 +382,6 @@ readPixels (const char pFilename[],
IMATH::Box2i lDataWindow = lFile.header().dataWindow();

int lWidth = lDataWindow.max.x - lDataWindow.min.x + 1;
//int lHeight = lDataWindow.max.y - lDataWindow.min.y + 1;

FrameBuffer lInputFrameBuffer;

Expand Down

0 comments on commit 5cbf3cb

Please sign in to comment.