From c8a7f6a5ebce9a6d5bd9a3320bc746221789f407 Mon Sep 17 00:00:00 2001 From: Cary Phillips Date: Mon, 24 Jun 2019 17:20:02 -0700 Subject: [PATCH] Various fixes to address compiler warnings: - removed unused variables and functions - added default cases to switch statements - member initialization order in class constructors - lots of signed/unsigned comparisons fixed either by changing a loop iterator from int to size_t, or by selective type casting. Signed-off-by: Cary Phillips --- IlmBase/IlmThread/IlmThreadPool.cpp | 4 +- IlmBase/Imath/ImathFun.cpp | 4 +- IlmBase/Imath/ImathMatrixAlgo.cpp | 12 ++--- IlmBase/ImathTest/testBoxAlgo.cpp | 42 +--------------- IlmBase/ImathTest/testExtractEuler.cpp | 1 - IlmBase/ImathTest/testExtractSHRT.cpp | 1 - IlmBase/ImathTest/testJacobiEigenSolver.cpp | 16 +++--- IlmBase/ImathTest/testLineAlgo.cpp | 1 - IlmBase/ImathTest/testProcrustes.cpp | 4 +- IlmBase/ImathTest/testShear.cpp | 1 - OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp | 55 +-------------------- OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp | 2 - OpenEXR/IlmImf/ImfDwaCompressorSimd.h | 4 +- OpenEXR/IlmImf/ImfRgbaFile.cpp | 3 +- OpenEXR/IlmImf/ImfScanLineInputFile.cpp | 8 +++ OpenEXR/IlmImf/ImfTiledOutputFile.cpp | 2 - PyIlmBase/PyIex/PyIexTypeTranslator.h | 2 +- PyIlmBase/PyImath/PyImathAutovectorize.h | 2 +- PyIlmBase/PyImath/PyImathBox.cpp | 2 +- PyIlmBase/PyImath/PyImathBoxArrayImpl.h | 2 +- PyIlmBase/PyImath/PyImathEuler.cpp | 4 ++ PyIlmBase/PyImath/PyImathFixedArray.h | 16 +++--- PyIlmBase/PyImath/PyImathFixedArray2D.h | 32 ++++++------ PyIlmBase/PyImath/PyImathFixedVArray.cpp | 12 ++--- PyIlmBase/PyImath/PyImathFixedVArray.h | 4 +- PyIlmBase/PyImath/PyImathStringArray.cpp | 6 +-- PyIlmBase/PyImath/imathmodule.cpp | 4 +- 27 files changed, 79 insertions(+), 167 deletions(-) diff --git a/IlmBase/IlmThread/IlmThreadPool.cpp b/IlmBase/IlmThread/IlmThreadPool.cpp index 24ca739572..b1b2e91d79 100644 --- a/IlmBase/IlmThread/IlmThreadPool.cpp +++ b/IlmBase/IlmThread/IlmThreadPool.cpp @@ -156,8 +156,8 @@ struct ThreadPool::Data ThreadPoolProvider *provider; ThreadPoolProvider *oldprovider; #else - std::atomic provider; std::atomic provUsers; + std::atomic provider; #endif }; @@ -459,7 +459,7 @@ class NullThreadPoolProvider : public ThreadPoolProvider // struct TaskGroup::Data // -TaskGroup::Data::Data (): isEmpty (1), numPending (0) +TaskGroup::Data::Data () : numPending (0), isEmpty (1) { // empty } diff --git a/IlmBase/Imath/ImathFun.cpp b/IlmBase/Imath/ImathFun.cpp index 65cf62024b..0fe9f041e4 100644 --- a/IlmBase/Imath/ImathFun.cpp +++ b/IlmBase/Imath/ImathFun.cpp @@ -41,7 +41,7 @@ IMATH_INTERNAL_NAMESPACE_SOURCE_ENTER float succf (float f) { - union {float f; int i;} u; + union {float f; unsigned int i;} u; u.f = f; if ((u.i & 0x7f800000) == 0x7f800000) @@ -76,7 +76,7 @@ succf (float f) float predf (float f) { - union {float f; int i;} u; + union {float f; unsigned int i;} u; u.f = f; if ((u.i & 0x7f800000) == 0x7f800000) diff --git a/IlmBase/Imath/ImathMatrixAlgo.cpp b/IlmBase/Imath/ImathMatrixAlgo.cpp index 0cafd5c060..3f6396872b 100644 --- a/IlmBase/Imath/ImathMatrixAlgo.cpp +++ b/IlmBase/Imath/ImathMatrixAlgo.cpp @@ -115,7 +115,7 @@ procrustesRotationAndTranslation (const Vec3* A, const Vec3* B, const T* w if (weights == 0) { - for (int i = 0; i < numPoints; ++i) + for (size_t i = 0; i < numPoints; ++i) { Acenter += (V3d) A[i]; Bcenter += (V3d) B[i]; @@ -124,7 +124,7 @@ procrustesRotationAndTranslation (const Vec3* A, const Vec3* B, const T* w } else { - for (int i = 0; i < numPoints; ++i) + for (size_t i = 0; i < numPoints; ++i) { const double w = weights[i]; weightsSum += w; @@ -152,12 +152,12 @@ procrustesRotationAndTranslation (const Vec3* A, const Vec3* B, const T* w M33d C (0.0); if (weights == 0) { - for (int i = 0; i < numPoints; ++i) + for (size_t i = 0; i < numPoints; ++i) C += outerProduct ((V3d) B[i] - Bcenter, (V3d) A[i] - Acenter); } else { - for (int i = 0; i < numPoints; ++i) + for (size_t i = 0; i < numPoints; ++i) { const double w = weights[i]; C += outerProduct (w * ((V3d) B[i] - Bcenter), (V3d) A[i] - Acenter); @@ -197,12 +197,12 @@ procrustesRotationAndTranslation (const Vec3* A, const Vec3* B, const T* w KahanSum traceATA; if (weights == 0) { - for (int i = 0; i < numPoints; ++i) + for (size_t i = 0; i < numPoints; ++i) traceATA += ((V3d) A[i] - Acenter).length2(); } else { - for (int i = 0; i < numPoints; ++i) + for (size_t i = 0; i < numPoints; ++i) traceATA += ((double) weights[i]) * ((V3d) A[i] - Acenter).length2(); } diff --git a/IlmBase/ImathTest/testBoxAlgo.cpp b/IlmBase/ImathTest/testBoxAlgo.cpp index 9be1b7c22f..9eceba3574 100644 --- a/IlmBase/ImathTest/testBoxAlgo.cpp +++ b/IlmBase/ImathTest/testBoxAlgo.cpp @@ -356,7 +356,7 @@ entryAndExitPoints1 () Box3f () }; - for (int i = 0; i < sizeof (boxes) / sizeof (boxes[0]); ++i) + for (size_t i = 0; i < sizeof (boxes) / sizeof (boxes[0]); ++i) testEntryAndExitPoints (boxes[i]); } @@ -738,7 +738,7 @@ rayBoxIntersection1 () Box3f () }; - for (int i = 0; i < sizeof (boxes) / sizeof (boxes[0]); ++i) + for (size_t i = 0; i < sizeof (boxes) / sizeof (boxes[0]); ++i) testRayBoxIntersection (boxes[i]); } @@ -910,44 +910,6 @@ boxMatrixTransform () } -void -pointInBox () -{ - cout << " closest point in box" << endl; - - Box3f box (V3f (1, 2, 3), V3f (5, 4, 6)); - - // - // Points outside the box - // - - assert (closestPointInBox (V3f (0, 0, 0), box) == V3f (1, 2, 3)); - assert (closestPointInBox (V3f (7, 7, 7), box) == V3f (5, 4, 6)); - - assert (closestPointInBox (V3f (2, 3, 0), box) == V3f (2, 3, 3)); - assert (closestPointInBox (V3f (2, 3, 7), box) == V3f (2, 3, 6)); - - assert (closestPointInBox (V3f (2, 0, 4), box) == V3f (2, 2, 4)); - assert (closestPointInBox (V3f (2, 7, 4), box) == V3f (2, 4, 4)); - - assert (closestPointInBox (V3f (0, 3, 4), box) == V3f (1, 3, 4)); - assert (closestPointInBox (V3f (7, 3, 4), box) == V3f (5, 3, 4)); - - // - // Points inside the box - // - - assert (closestPointInBox (V3f (1.5, 3, 5), box) == V3f (1.5, 3, 5)); - assert (closestPointInBox (V3f (4.5, 3, 5), box) == V3f (4.5, 3, 5)); - - assert (closestPointInBox (V3f (2, 2.5, 4), box) == V3f (2, 2.5, 4)); - assert (closestPointInBox (V3f (2, 3.5, 4), box) == V3f (2, 3.5, 4)); - - assert (closestPointInBox (V3f (2, 3, 3.5), box) == V3f (2, 3, 3.5)); - assert (closestPointInBox (V3f (2, 3, 5.5), box) == V3f (2, 3, 5.5)); -} - - void pointInAndOnBox () { diff --git a/IlmBase/ImathTest/testExtractEuler.cpp b/IlmBase/ImathTest/testExtractEuler.cpp index 1a8e92050e..311c01e3ae 100644 --- a/IlmBase/ImathTest/testExtractEuler.cpp +++ b/IlmBase/ImathTest/testExtractEuler.cpp @@ -48,7 +48,6 @@ using namespace IMATH_INTERNAL_NAMESPACE; namespace { float rad (float deg) {return deg * (M_PI / 180);} -float deg (float rad) {return rad * (180 / M_PI);} M44f diff --git a/IlmBase/ImathTest/testExtractSHRT.cpp b/IlmBase/ImathTest/testExtractSHRT.cpp index 97401a26ff..6661f6f025 100644 --- a/IlmBase/ImathTest/testExtractSHRT.cpp +++ b/IlmBase/ImathTest/testExtractSHRT.cpp @@ -57,7 +57,6 @@ using namespace IMATH_INTERNAL_NAMESPACE; namespace { float rad (float deg) {return deg * (M_PI / 180);} -float deg (float rad) {return rad * (180 / M_PI);} void diff --git a/IlmBase/ImathTest/testJacobiEigenSolver.cpp b/IlmBase/ImathTest/testJacobiEigenSolver.cpp index 93eb29e052..e2e5f14054 100644 --- a/IlmBase/ImathTest/testJacobiEigenSolver.cpp +++ b/IlmBase/ImathTest/testJacobiEigenSolver.cpp @@ -85,8 +85,8 @@ void verifyOrthonormal (const TM& A, const typename TM::BaseType threshold) { const TM prod = A * A.transposed(); - for (int i = 0; i < TM::dimensions(); ++i) - for (int j = 0; j < TM::dimensions(); ++j) + for (size_t i = 0; i < TM::dimensions(); ++i) + for (size_t j = 0; j < TM::dimensions(); ++j) if (i == j) assert (std::abs (prod[i][j] - 1) < threshold); else @@ -100,8 +100,8 @@ computeThreshold(const TM& A) typedef typename TM::BaseType T; T maxAbsEntry(0); - for (int i = 0; i < TM::dimensions(); ++i) - for (int j = 0; j < TM::dimensions(); ++j) + for (size_t i = 0; i < TM::dimensions(); ++i) + for (size_t j = 0; j < TM::dimensions(); ++j) maxAbsEntry = std::max (maxAbsEntry, std::abs(A[i][j])); const T eps = std::numeric_limits::epsilon(); @@ -135,8 +135,8 @@ testJacobiEigenSolver(const TM& A) // Determinant of A and S TM MS; - for (int i = 0; i < TM::dimensions(); ++i) - for (int j = 0; j < TM::dimensions(); ++j) + for (size_t i = 0; i < TM::dimensions(); ++i) + for (size_t j = 0; j < TM::dimensions(); ++j) if(i == j) MS[i][j] = S[i]; else @@ -148,8 +148,8 @@ testJacobiEigenSolver(const TM& A) // A = V * S * V^T TM MA = V * MS * V.transposed(); - for (int i = 0; i < TM::dimensions(); ++i) - for (int j =0; j < TM::dimensions(); ++j) + for (size_t i = 0; i < TM::dimensions(); ++i) + for (size_t j =0; j < TM::dimensions(); ++j) assert(abs(A[i][j]-MA[i][j]) < threshold); } diff --git a/IlmBase/ImathTest/testLineAlgo.cpp b/IlmBase/ImathTest/testLineAlgo.cpp index ad79c587ec..21a642c033 100644 --- a/IlmBase/ImathTest/testLineAlgo.cpp +++ b/IlmBase/ImathTest/testLineAlgo.cpp @@ -399,7 +399,6 @@ testIntersect () V3f p1 = v0 * b.x + v1 * b.y + v2 * b.z; V3f p0; - int j = 0; do { diff --git a/IlmBase/ImathTest/testProcrustes.cpp b/IlmBase/ImathTest/testProcrustes.cpp index 71cfe10b74..7e86d41c28 100644 --- a/IlmBase/ImathTest/testProcrustes.cpp +++ b/IlmBase/ImathTest/testProcrustes.cpp @@ -151,8 +151,6 @@ void verifyProcrustes (const std::vector >& from, const std::vector >& to) { - typedef IMATH_INTERNAL_NAMESPACE::Vec3 V3; - const T eps = std::sqrt(std::numeric_limits::epsilon()); const size_t n = from.size(); @@ -242,7 +240,7 @@ verifyProcrustes (const std::vector >& from, IMATH_INTERNAL_NAMESPACE::V3d netForce(0); IMATH_INTERNAL_NAMESPACE::V3d netTorque(0); - for (int iPoint = 0; iPoint < n; ++iPoint) + for (size_t iPoint = 0; iPoint < n; ++iPoint) { const IMATH_INTERNAL_NAMESPACE::V3d force = weights[iPoint] * (from[iPoint]*m - to[iPoint]); netForce += force; diff --git a/IlmBase/ImathTest/testShear.cpp b/IlmBase/ImathTest/testShear.cpp index 17832b1fc2..7783f7d4e4 100644 --- a/IlmBase/ImathTest/testShear.cpp +++ b/IlmBase/ImathTest/testShear.cpp @@ -54,7 +54,6 @@ testShear () const float epsilon = IMATH_INTERNAL_NAMESPACE::limits< float >::epsilon(); - float array[6] = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F }; IMATH_INTERNAL_NAMESPACE::Shear6f testConstructor1; IMATH_INTERNAL_NAMESPACE::Shear6f testConstructor2( testConstructor1 ); diff --git a/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp b/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp index e34f606d95..9addc914ba 100644 --- a/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp +++ b/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp @@ -458,59 +458,6 @@ readTileData (InputStreamMutex *streamData, } -void -readNextTileData (InputStreamMutex *streamData, - DeepTiledInputFile::Data *ifd, - int &dx, int &dy, - int &lx, int &ly, - char * & buffer, - Int64 &dataSize, - Int64 &unpackedDataSize) -{ - // - // Read the next tile block from the file - // - - // - // Read the first few bytes of the tile (the header). - // - - Xdr::read (*streamData->is, dx); - Xdr::read (*streamData->is, dy); - Xdr::read (*streamData->is, lx); - Xdr::read (*streamData->is, ly); - - Int64 tableSize; - Xdr::read (*streamData->is, tableSize); - - Xdr::read (*streamData->is, dataSize); - Xdr::read (*streamData->is, unpackedDataSize); - - // - // Skip the pixel sample count table because we have read this data. - // - - Xdr::skip (*streamData->is, tableSize); - - // - // Read the pixel data. - // - - streamData->is->read (buffer, dataSize); - - // - // Keep track of which tile is the next one in - // the file, so that we can avoid redundant seekg() - // operations (seekg() can be fairly expensive). - // - - streamData->currentPosition += 4 * Xdr::size() + - 3 * Xdr::size() + - tableSize + - dataSize; -} - - // // A TileBufferTask encapsulates the task of uncompressing // a single tile and copying it into the frame buffer. @@ -1957,7 +1904,7 @@ DeepTiledInputFile::totalTiles() const for (int i_lx = 0; i_lx < numXLevels (); ++i_lx) numAllTiles += numXTiles (i_lx) * numYTiles (i_ly); - break; + break; default: diff --git a/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp b/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp index ef79135a42..095453255b 100644 --- a/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp +++ b/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp @@ -1465,13 +1465,11 @@ DeepTiledOutputFile::writeTiles (int dx1, int dx2, int dy1, int dy2, swap (dy1, dy2); int dyStart = dy1; - int dyStop = dy2 + 1; int dY = 1; if (_data->lineOrder == DECREASING_Y) { dyStart = dy2; - dyStop = dy1 - 1; dY = -1; } diff --git a/OpenEXR/IlmImf/ImfDwaCompressorSimd.h b/OpenEXR/IlmImf/ImfDwaCompressorSimd.h index c14ae7a323..469a3383f0 100644 --- a/OpenEXR/IlmImf/ImfDwaCompressorSimd.h +++ b/OpenEXR/IlmImf/ImfDwaCompressorSimd.h @@ -87,7 +87,7 @@ class SimdAlignedBuffer64 alloc(); } - SimdAlignedBuffer64(const SimdAlignedBuffer64 &rhs): _handle(0) + SimdAlignedBuffer64(const SimdAlignedBuffer64 &rhs): _buffer (0), _handle(0) { alloc(); memcpy (_buffer, rhs._buffer, 64 * sizeof (T)); @@ -101,7 +101,7 @@ class SimdAlignedBuffer64 #if __cplusplus >= 201103L SimdAlignedBuffer64(SimdAlignedBuffer64 &&rhs) noexcept - : _handle(rhs._handle), _buffer(rhs._buffer) + : _buffer(rhs._buffer), _handle(rhs._handle) { rhs._handle = nullptr; rhs._buffer = nullptr; diff --git a/OpenEXR/IlmImf/ImfRgbaFile.cpp b/OpenEXR/IlmImf/ImfRgbaFile.cpp index c2b604a196..74d5ea8c16 100644 --- a/OpenEXR/IlmImf/ImfRgbaFile.cpp +++ b/OpenEXR/IlmImf/ImfRgbaFile.cpp @@ -167,9 +167,10 @@ cachePadding (ptrdiff_t size) // we are running on. (It is ok if CACHE_LINE_SIZE is larger // than a real cache line.) // + // CACHE_LINE_SIZE = (1 << LOG2_CACHE_LINE_SIZE) + // static int LOG2_CACHE_LINE_SIZE = 8; - static const ptrdiff_t CACHE_LINE_SIZE = (1 << LOG2_CACHE_LINE_SIZE); int i = LOG2_CACHE_LINE_SIZE + 2; diff --git a/OpenEXR/IlmImf/ImfScanLineInputFile.cpp b/OpenEXR/IlmImf/ImfScanLineInputFile.cpp index c3eadb7941..a6620c7fc7 100644 --- a/OpenEXR/IlmImf/ImfScanLineInputFile.cpp +++ b/OpenEXR/IlmImf/ImfScanLineInputFile.cpp @@ -1418,6 +1418,10 @@ ScanLineInputFile::setFrameBuffer (const FrameBuffer &frameBuffer) case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT : offset+=2; break; + case OPENEXR_IMF_INTERNAL_NAMESPACE::NUM_PIXELTYPES: + default: + // not possible. + break; } ++i; } @@ -1488,6 +1492,10 @@ ScanLineInputFile::setFrameBuffer (const FrameBuffer &frameBuffer) case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT : offset+=2; break; + case OPENEXR_IMF_INTERNAL_NAMESPACE::NUM_PIXELTYPES: + default: + // not possible. + break; } } diff --git a/OpenEXR/IlmImf/ImfTiledOutputFile.cpp b/OpenEXR/IlmImf/ImfTiledOutputFile.cpp index b9572d0bc2..de6cafe64f 100644 --- a/OpenEXR/IlmImf/ImfTiledOutputFile.cpp +++ b/OpenEXR/IlmImf/ImfTiledOutputFile.cpp @@ -1230,13 +1230,11 @@ TiledOutputFile::writeTiles (int dx1, int dx2, int dy1, int dy2, swap (dy1, dy2); int dyStart = dy1; - int dyStop = dy2 + 1; int dY = 1; if (_data->lineOrder == DECREASING_Y) { dyStart = dy2; - dyStop = dy1 - 1; dY = -1; } diff --git a/PyIlmBase/PyIex/PyIexTypeTranslator.h b/PyIlmBase/PyIex/PyIexTypeTranslator.h index c457f34110..f613474f38 100644 --- a/PyIlmBase/PyIex/PyIexTypeTranslator.h +++ b/PyIlmBase/PyIex/PyIexTypeTranslator.h @@ -306,7 +306,7 @@ TypeTranslator::ClassDesc::ClassDesc template TypeTranslator::ClassDesc::~ClassDesc () { - for (int i = 0; i < _derivedClasses.size(); ++i) + for (size_t i = 0; i < _derivedClasses.size(); ++i) delete _derivedClasses[i]; } diff --git a/PyIlmBase/PyImath/PyImathAutovectorize.h b/PyIlmBase/PyImath/PyImathAutovectorize.h index e9df0b6240..f9e9542ea7 100644 --- a/PyIlmBase/PyImath/PyImathAutovectorize.h +++ b/PyIlmBase/PyImath/PyImathAutovectorize.h @@ -738,7 +738,7 @@ struct VectorizedVoidMaskableMemberFunction1 { size_t len = cls.match_dimension(arg1, false); op_precompute::apply(len); - if (cls.isMaskedReference() && arg1.len() == cls.unmaskedLength()) + if (cls.isMaskedReference() && (size_t) arg1.len() == cls.unmaskedLength()) { // class is masked, and the unmasked length matches the right hand side VectorizedMaskedVoidOperation1 vop(cls,arg1); diff --git a/PyIlmBase/PyImath/PyImathBox.cpp b/PyIlmBase/PyImath/PyImathBox.cpp index baea0e8d0d..910f7438fd 100644 --- a/PyIlmBase/PyImath/PyImathBox.cpp +++ b/PyIlmBase/PyImath/PyImathBox.cpp @@ -316,7 +316,7 @@ box_extendBy(IMATH_NAMESPACE::Box &box, const PyImath::FixedArray &points) std::vector > boxes(numBoxes); ExtendByTask task(boxes,points); dispatchTask(task,points.len()); - for (int i=0; i > &va, Py_ssize_t index, const t Box v; v.min = extract(t[0]); v.max = extract(t[1]); - va[va.canonical_index(index)] = v; + va[(size_t)va.canonical_index(index)] = v; } else THROW(IEX_NAMESPACE::LogicExc, "tuple of length 2 expected"); diff --git a/PyIlmBase/PyImath/PyImathEuler.cpp b/PyIlmBase/PyImath/PyImathEuler.cpp index b18cae32ad..18e44cc061 100644 --- a/PyIlmBase/PyImath/PyImathEuler.cpp +++ b/PyIlmBase/PyImath/PyImathEuler.cpp @@ -113,6 +113,8 @@ static std::string nameOfOrder(typename IMATH_NAMESPACE::Euler::Order order) return "EULER_ZYZr"; case IMATH_NAMESPACE::Euler::ZXZr: return "EULER_ZXZr"; + default: + break; } return ""; @@ -306,6 +308,8 @@ static typename Euler::Order interpretOrder(typename IMATH_NAMESPACE::Eulerf: { o = Euler::ZXZr; }break; + default: + break; } return o; diff --git a/PyIlmBase/PyImath/PyImathFixedArray.h b/PyIlmBase/PyImath/PyImathFixedArray.h index 6a9d034abd..819d7273db 100644 --- a/PyIlmBase/PyImath/PyImathFixedArray.h +++ b/PyIlmBase/PyImath/PyImathFixedArray.h @@ -116,7 +116,7 @@ class FixedArray } boost::shared_array a(new T[length]); T tmp = FixedArrayDefaultValue::value(); - for (size_t i=0; i a(new T[length]); - for (size_t i=0; i= _length || index < 0) { + if (index < 0) index += len(); + if (index >= len() || index < 0) { PyErr_SetString(PyExc_IndexError, "Index out of range"); boost::python::throw_error_already_set(); } @@ -345,7 +345,7 @@ class FixedArray extract_slice_indices(index,start,end,step,slicelength); // we have a valid range of indices - if (data.len() != slicelength) { + if ((size_t)data.len() != slicelength) { PyErr_SetString(PyExc_IndexError, "Dimensions of source do not match destination"); boost::python::throw_error_already_set(); } @@ -374,7 +374,7 @@ class FixedArray } size_t len = match_dimension(mask); - if (data.len() == len) + if ((size_t)data.len() == len) { for (size_t i = 0; i < len; ++i) if (mask[i]) _ptr[i*_stride] = data[i]; @@ -385,7 +385,7 @@ class FixedArray for (size_t i = 0; i < len; ++i) if (mask[i]) count++; - if (data.len() != count) { + if ((size_t)data.len() != count) { throw IEX_NAMESPACE::ArgExc("Dimensions of source data do not match destination either masked or unmasked"); } @@ -493,7 +493,7 @@ class FixedArray throwExc = true; else if (_indices) { - if (_unmaskedLength != a1.len()) + if (_unmaskedLength != (size_t) a1.len()) throwExc = true; } else diff --git a/PyIlmBase/PyImath/PyImathFixedArray2D.h b/PyIlmBase/PyImath/PyImathFixedArray2D.h index 8c628f1695..19969e3b0f 100644 --- a/PyIlmBase/PyImath/PyImathFixedArray2D.h +++ b/PyIlmBase/PyImath/PyImathFixedArray2D.h @@ -183,7 +183,7 @@ class FixedArray2D size_t canonical_index(Py_ssize_t index, size_t length) const { if (index < 0) index += length; - if (index >= length || index < 0) { + if ((size_t) index >= length || index < 0) { PyErr_SetString(PyExc_IndexError, "Index out of range"); boost::python::throw_error_already_set(); } @@ -355,7 +355,7 @@ class FixedArray2D setitem_array1d_mask(const FixedArray2D &mask, const FixedArray &data) { IMATH_NAMESPACE::Vec2 len = match_dimension(mask); - if (data.len() == len.x*len.y) { + if ((size_t) data.len() == len.x*len.y) { for (size_t j = 0, z = 0; j < len.y; j++) for (size_t i=0; i apply_array2d_unary_op(const FixedArray2D &a1) { IMATH_NAMESPACE::Vec2 len = a1.len(); FixedArray2D retval(len.x,len.y); - for (int j=0; j::apply(a1(i,j)); } } @@ -503,8 +503,8 @@ FixedArray2D apply_array2d_array2d_binary_op(const FixedArray2D &a1, co { IMATH_NAMESPACE::Vec2 len = a1.match_dimension(a2); FixedArray2D retval(len.x,len.y); - for (int j=0; j::apply(a1(i,j),a2(i,j)); } } @@ -516,8 +516,8 @@ FixedArray2D apply_array2d_scalar_binary_op(const FixedArray2D &a1, con { IMATH_NAMESPACE::Vec2 len = a1.len(); FixedArray2D retval(len.x,len.y); - for (int j=0; j::apply(a1(i,j),a2); } } @@ -529,8 +529,8 @@ FixedArray2D apply_array2d_scalar_binary_rop(const FixedArray2D &a1, co { IMATH_NAMESPACE::Vec2 len = a1.len(); FixedArray2D retval(len.x,len.y); - for (int j=0; j::apply(a2,a1(i,j)); } } @@ -542,8 +542,8 @@ template