From 886e1c2f16157ddd2f05ab49076574ef9f487fe3 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 18 Jun 2018 22:12:19 +0200 Subject: [PATCH] general: fix many compilation warnings in GCC 8 --- contrib/src/rplight/internalLightManager.cxx | 2 +- contrib/src/rplight/pointerSlotStorage.h | 2 +- contrib/src/rplight/rpLight.I | 2 +- contrib/src/rplight/rpLight.h | 2 +- contrib/src/rplight/shadowAtlas.cxx | 6 +-- direct/src/dcparser/dcLexer.cxx.prebuilt | 2 +- direct/src/dcparser/dcLexer.lxx | 2 +- dtool/src/interrogatedb/py_panda.I | 4 ++ dtool/src/interrogatedb/py_wrappers.cxx | 13 ----- panda/src/bullet/bulletBodyNode.cxx | 6 +-- panda/src/bullet/bulletGhostNode.cxx | 3 +- panda/src/bullet/bulletHelper.cxx | 2 +- panda/src/bullet/bulletSoftBodyNode.cxx | 2 +- panda/src/bullet/bulletTriangleMesh.cxx | 10 ++-- panda/src/bullet/bulletWheel.I | 2 +- panda/src/bullet/bulletWorld.cxx | 40 ++++++++-------- panda/src/collide/collisionPolygon.I | 6 +-- panda/src/collide/collisionPolygon.h | 4 +- panda/src/display/graphicsStateGuardian.cxx | 2 +- panda/src/egg/lexer.cxx.prebuilt | 2 +- panda/src/egg/lexer.lxx | 2 +- panda/src/egldisplay/eglGraphicsWindow.cxx | 2 +- panda/src/express/patchfile.cxx | 6 +-- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 2 +- panda/src/glstuff/glGeomMunger_src.cxx | 2 +- panda/src/glstuff/glGraphicsBuffer_src.cxx | 8 ++-- .../glstuff/glGraphicsStateGuardian_src.cxx | 15 ++++-- panda/src/glstuff/glShaderContext_src.cxx | 17 ++++--- panda/src/glstuff/glShaderContext_src.h | 2 +- panda/src/gobj/geomLinestrips.cxx | 2 +- panda/src/gobj/geomVertexArrayFormat.cxx | 4 +- panda/src/gobj/geomVertexData.I | 6 +-- panda/src/gobj/geomVertexData.cxx | 12 ++--- panda/src/gobj/geomVertexData.h | 4 +- panda/src/gobj/geomVertexReader.cxx | 2 +- panda/src/gobj/geomVertexWriter.cxx | 2 +- panda/src/gobj/shader.cxx | 12 ++--- panda/src/gobj/texture.cxx | 6 +-- panda/src/linmath/lsimpleMatrix.I | 27 ----------- panda/src/linmath/lsimpleMatrix.h | 3 -- panda/src/ode/odeTriMeshData.cxx | 4 +- panda/src/parametrics/nurbsSurfaceResult.cxx | 12 ++--- .../particlesystem/spriteParticleRenderer.cxx | 4 +- panda/src/pgraph/camera.I | 2 +- panda/src/pgraph/geomTransformer.cxx | 4 +- panda/src/pgraphnodes/shaderGenerator.cxx | 2 +- panda/src/physics/physicsObject.cxx | 2 +- panda/src/pipeline/pipeline.cxx | 2 +- panda/src/pnmimage/pfmFile.cxx | 47 ++++++++++--------- panda/src/pnmimage/pnmimage_base.h | 2 +- panda/src/pnmimagetypes/pnmFileTypeTGA.cxx | 4 +- panda/src/pstatclient/pStatCollector.I | 14 ------ panda/src/pstatclient/pStatCollector.h | 8 ++-- panda/src/putil/bitArray.cxx | 20 ++++---- panda/src/putil/doubleBitMask.I | 8 ++-- panda/src/putil/factoryBase.cxx | 45 +++--------------- panda/src/putil/factoryBase.h | 19 ++++---- panda/src/putil/factoryParams.I | 39 --------------- panda/src/putil/factoryParams.h | 12 ++--- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 4 +- panda/src/tinydisplay/ztriangle.h | 6 +-- panda/src/tinydisplay/ztriangle_two.h | 16 +++++-- panda/src/x11display/x11GraphicsWindow.cxx | 2 +- pandatool/src/objegg/objToEggConverter.cxx | 6 +-- pandatool/src/vrml/vrmlLexer.cxx.prebuilt | 2 +- pandatool/src/vrml/vrmlLexer.lxx | 2 +- pandatool/src/xfile/xLexer.cxx.prebuilt | 2 +- pandatool/src/xfile/xLexer.lxx | 2 +- 68 files changed, 219 insertions(+), 323 deletions(-) diff --git a/contrib/src/rplight/internalLightManager.cxx b/contrib/src/rplight/internalLightManager.cxx index 3d80294f82..616e089cbc 100644 --- a/contrib/src/rplight/internalLightManager.cxx +++ b/contrib/src/rplight/internalLightManager.cxx @@ -135,7 +135,7 @@ void InternalLightManager::setup_shadows(RPLight* light) { } // Init all sources - for (int i = 0; i < num_sources; ++i) { + for (size_t i = 0; i < num_sources; ++i) { ShadowSource* source = light->get_shadow_source(i); // Set the source as dirty, so it gets updated in the beginning diff --git a/contrib/src/rplight/pointerSlotStorage.h b/contrib/src/rplight/pointerSlotStorage.h index c37102574f..d63594209b 100644 --- a/contrib/src/rplight/pointerSlotStorage.h +++ b/contrib/src/rplight/pointerSlotStorage.h @@ -170,7 +170,7 @@ public: _num_entries--; // Update maximum index - if (slot == _max_index) { + if ((int)slot == _max_index) { while (_max_index >= 0 && !_data[_max_index--]); } } diff --git a/contrib/src/rplight/rpLight.I b/contrib/src/rplight/rpLight.I index 9cde259478..c0e2422651 100644 --- a/contrib/src/rplight/rpLight.I +++ b/contrib/src/rplight/rpLight.I @@ -33,7 +33,7 @@ * * @return Amount of shadow sources */ -inline int RPLight::get_num_shadow_sources() const { +inline size_t RPLight::get_num_shadow_sources() const { return _shadow_sources.size(); } diff --git a/contrib/src/rplight/rpLight.h b/contrib/src/rplight/rpLight.h index 1a104f8ac7..51bca24a76 100644 --- a/contrib/src/rplight/rpLight.h +++ b/contrib/src/rplight/rpLight.h @@ -57,7 +57,7 @@ public: virtual void update_shadow_sources() = 0; virtual void write_to_command(GPUCommand &cmd); - inline int get_num_shadow_sources() const; + inline size_t get_num_shadow_sources() const; inline ShadowSource* get_shadow_source(size_t index) const; inline void clear_shadow_sources(); diff --git a/contrib/src/rplight/shadowAtlas.cxx b/contrib/src/rplight/shadowAtlas.cxx index fa2b2d3076..2f76aae33d 100644 --- a/contrib/src/rplight/shadowAtlas.cxx +++ b/contrib/src/rplight/shadowAtlas.cxx @@ -173,12 +173,12 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h void ShadowAtlas::free_region(const LVecBase4i& region) { // Out of bounds check, can't hurt nassertv(region.get_x() >= 0 && region.get_y() >= 0); - nassertv(region.get_x() + region.get_z() <= _num_tiles && region.get_y() + region.get_w() <= _num_tiles); + nassertv(region.get_x() + region.get_z() <= (int)_num_tiles && region.get_y() + region.get_w() <= (int)_num_tiles); _num_used_tiles -= region.get_z() * region.get_w(); - for (size_t x = 0; x < region.get_z(); ++x) { - for (size_t y = 0; y < region.get_w(); ++y) { + for (int x = 0; x < region.get_z(); ++x) { + for (int y = 0; y < region.get_w(); ++y) { // Could do an assert here, that the tile should have been used (=true) before set_tile(region.get_x() + x, region.get_y() + y, false); } diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index 70333927fe..660f96b5cb 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -744,7 +744,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index 423bfe9a99..3c20a69b5f 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -169,7 +169,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 8f889768ea..540e9ee58d 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -31,6 +31,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into) { if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == target_class) { into = (T *)DtoolInstance_VOID_PTR(self); + } else { + return false; } } else { into = (T *)DtoolInstance_UPCAST(self, *target_class); @@ -52,6 +54,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == &target_class) { into = (T *)DtoolInstance_VOID_PTR(self); + } else { + return false; } } else { into = (T *)DtoolInstance_UPCAST(self, target_class); diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index c09df0d5ab..71a5a38ffd 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -1209,19 +1209,6 @@ static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { return result; } -static PySequenceMethods Dtool_MappingWrapper_Keys_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_MappingWrapper_Items_getitem, - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_MappingWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - PyTypeObject Dtool_MappingWrapper_Keys_Type = { PyVarObject_HEAD_INIT(nullptr, 0) "sequence wrapper", diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 9c2553c892..0a4bbc40c8 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -784,7 +784,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { PT(BulletTriangleMesh) mesh = nullptr; - for (int j=0; jget_num_solids(); j++) { + for (size_t j = 0; j < cnode->get_num_solids(); ++j) { CPT(CollisionSolid) solid = cnode->get_solid(j); TypeHandle type = solid->get_type(); @@ -819,9 +819,9 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { mesh = new BulletTriangleMesh(); } - for (int i=2; i < polygon->get_num_points(); i++ ) { + for (size_t i = 2; i < polygon->get_num_points(); ++i) { LPoint3 p1 = polygon->get_point(0); - LPoint3 p2 = polygon->get_point(i-1); + LPoint3 p2 = polygon->get_point(i - 1); LPoint3 p3 = polygon->get_point(i); mesh->do_add_triangle(p1, p2, p3, true); diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index fad9e8141a..b4008820a1 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -97,8 +97,7 @@ do_transform_changed() { if (ts->has_scale()) { LVecBase3 scale = ts->get_scale(); if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { - for (int i=0; i < _shapes.size(); i++) { - PT(BulletShape) shape = _shapes[i]; + for (BulletShape *shape : _shapes) { shape->do_set_local_scale(scale); } } diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index d5e3f503b4..e786e34d40 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -83,7 +83,7 @@ from_collision_solids(NodePath &np, bool clear) { bool BulletHelper:: is_tangible(CollisionNode *cnode) { - for (int j=0; jget_num_solids(); j++) { + for (size_t j = 0; j < cnode->get_num_solids(); ++j) { CPT(CollisionSolid) solid = cnode->get_solid(j); if (solid->is_tangible()) { return true; diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 4664ab75c5..9687935412 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -883,7 +883,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon } // Read indices - for (int i=0; iget_num_primitives(); i++) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { CPT(GeomPrimitive) prim = geom->get_primitive(i); prim = prim->decompose(); diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 34372e5130..368aa22fac 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -55,7 +55,7 @@ LPoint3 BulletTriangleMesh:: get_vertex(size_t index) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(index < _vertices.size(), LPoint3::zero()); + nassertr(index < (size_t)_vertices.size(), LPoint3::zero()); const btVector3 &vertex = _vertices[index]; return LPoint3(vertex[0], vertex[1], vertex[2]); } @@ -68,7 +68,7 @@ get_triangle(size_t index) const { LightMutexHolder holder(BulletWorld::get_global_lock()); index *= 3; - nassertr(index + 2 < _indices.size(), LVecBase3i::zero()); + nassertr(index + 2 < (size_t)_indices.size(), LVecBase3i::zero()); return LVecBase3i(_indices[index], _indices[index + 1], _indices[index + 2]); } @@ -228,7 +228,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } } - for (int k = 0; k < geom->get_num_primitives(); ++k) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim = geom->get_primitive(k); prim = prim->decompose(); @@ -271,7 +271,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } // Add triangles - for (int k = 0; k < geom->get_num_primitives(); ++k) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim = geom->get_primitive(k); prim = prim->decompose(); @@ -367,7 +367,7 @@ write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":" << endl; const IndexedMeshArray &array = _mesh.getIndexedMeshArray(); - for (size_t i = 0; i < array.size(); ++i) { + for (int i = 0; i < array.size(); ++i) { indent(out, indent_level + 2) << "IndexedMesh " << i << ":" << endl; const btIndexedMesh &mesh = array[0]; indent(out, indent_level + 4) << "num triangles:" << mesh.m_numTriangles << endl; diff --git a/panda/src/bullet/bulletWheel.I b/panda/src/bullet/bulletWheel.I index cbf82a40bc..0523ba9727 100644 --- a/panda/src/bullet/bulletWheel.I +++ b/panda/src/bullet/bulletWheel.I @@ -34,7 +34,7 @@ INLINE BulletWheelRaycastInfo:: INLINE BulletWheel BulletWheel:: empty() { - btWheelInfoConstructionInfo ci; + btWheelInfoConstructionInfo ci {}; btWheelInfo info(ci); return BulletWheel(info); diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index e4c395267c..fce29fd2ba 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -42,7 +42,7 @@ BulletWorld:: BulletWorld() { // Init groups filter matrix - for (int i=0; i<32; i++) { + for (size_t i = 0; i < 32; ++i) { _filter_cb2._collide[i].clear(); _filter_cb2._collide[i].set_bit(i); } @@ -253,20 +253,20 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { void BulletWorld:: do_sync_p2b(PN_stdfloat dt, int num_substeps) { - for (int i=0; i < _bodies.size(); i++) { - _bodies[i]->do_sync_p2b(); + for (BulletRigidBodyNode *body : _bodies) { + body->do_sync_p2b(); } - for (int i=0; i < _softbodies.size(); i++) { - _softbodies[i]->do_sync_p2b(); + for (BulletSoftBodyNode *softbody : _softbodies) { + softbody->do_sync_p2b(); } - for (int i=0; i < _ghosts.size(); i++) { - _ghosts[i]->do_sync_p2b(); + for (BulletGhostNode *ghost : _ghosts) { + ghost->do_sync_p2b(); } - for (int i=0; i < _characters.size(); i++) { - _characters[i]->do_sync_p2b(dt, num_substeps); + for (BulletBaseCharacterControllerNode *character : _characters) { + character->do_sync_p2b(dt, num_substeps); } } @@ -276,24 +276,24 @@ do_sync_p2b(PN_stdfloat dt, int num_substeps) { void BulletWorld:: do_sync_b2p() { - for (int i=0; i < _vehicles.size(); i++) { - _vehicles[i]->do_sync_b2p(); + for (BulletVehicle *vehicle : _vehicles) { + vehicle->do_sync_b2p(); } - for (int i=0; i < _bodies.size(); i++) { - _bodies[i]->do_sync_b2p(); + for (BulletRigidBodyNode *body : _bodies) { + body->do_sync_b2p(); } - for (int i=0; i < _softbodies.size(); i++) { - _softbodies[i]->do_sync_b2p(); + for (BulletSoftBodyNode *softbody : _softbodies) { + softbody->do_sync_b2p(); } - for (int i=0; i < _ghosts.size(); i++) { - _ghosts[i]->do_sync_b2p(); + for (BulletGhostNode *ghost : _ghosts) { + ghost->do_sync_b2p(); } - for (int i=0; i < _characters.size(); i++) { - _characters[i]->do_sync_b2p(); + for (BulletBaseCharacterControllerNode *character : _characters) { + character->do_sync_b2p(); } } @@ -1273,7 +1273,7 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co // cout << mask0 << " " << mask1 << endl; - for (int i=0; i<32; i++) { + for (size_t i = 0; i < 32; ++i) { if (mask0.get_bit(i)) { if ((_collide[i] & mask1) != 0) // cout << "collide: i=" << i << " _collide[i]" << _collide[i] << endl; diff --git a/panda/src/collide/collisionPolygon.I b/panda/src/collide/collisionPolygon.I index 4a048a3995..6c7785d730 100644 --- a/panda/src/collide/collisionPolygon.I +++ b/panda/src/collide/collisionPolygon.I @@ -57,7 +57,7 @@ CollisionPolygon() { /** * Returns the number of vertices of the CollisionPolygon. */ -INLINE int CollisionPolygon:: +INLINE size_t CollisionPolygon:: get_num_points() const { return _points.size(); } @@ -66,8 +66,8 @@ get_num_points() const { * Returns the nth vertex of the CollisionPolygon, expressed in 3-D space. */ INLINE LPoint3 CollisionPolygon:: -get_point(int n) const { - nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); +get_point(size_t n) const { + nassertr(n < _points.size(), LPoint3::zero()); LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); return to_3d(_points[n]._p, to_3d_mat); diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 1ef095fd92..f7fa771bfa 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -45,8 +45,8 @@ public: PUBLISHED: virtual LPoint3 get_collision_origin() const; - INLINE int get_num_points() const; - INLINE LPoint3 get_point(int n) const; + INLINE size_t get_num_points() const; + INLINE LPoint3 get_point(size_t n) const; MAKE_SEQ(get_points, get_num_points, get_point); diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 94330cfa11..1050f8372f 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -763,7 +763,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { // multiple times during a frame. Also, this might well be the only GSG // in the world anyway. int mi = state->_last_mi; - if (mi >= 0 && mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) { + if (mi >= 0 && (size_t)mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) { PT(GeomMunger) munger = mungers.get_data(mi); if (munger->is_registered()) { return munger; diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index c736ac335e..9e412bce1f 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -1145,7 +1145,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 1c07166635..e88e5a388f 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -200,7 +200,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index 29f7ffbf49..efb550c728 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -84,7 +84,7 @@ move_pointer(int device, int x, int y) { return true; } else { // Move a raw mouse. - if ((device < 1)||(device >= _input_devices.size())) { + if (device < 1 || (size_t)device >= _input_devices.size()) { return false; } _input_devices[device].set_pointer_in_window(x, y); diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 4c6d9984f4..a527d78a02 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -1111,7 +1111,7 @@ compute_mf_patches(ostream &write_stream, index_orig, index_new)) { return false; } - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_index_end(), false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_index_end(), false); } // Now walk through each subfile in the new multifile. If a particular @@ -1120,7 +1120,7 @@ compute_mf_patches(ostream &write_stream, // removed, we simply don't add it (we'll never even notice this case). int new_num_subfiles = mf_new.get_num_subfiles(); for (int ni = 0; ni < new_num_subfiles; ++ni) { - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_subfile_internal_start(ni), false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_subfile_internal_start(ni), false); string name = mf_new.get_subfile_name(ni); int oi = mf_orig.find_subfile(name); @@ -1517,7 +1517,7 @@ patch_subfile(ostream &write_stream, const Filename &filename, IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end, IStreamWrapper &stream_new, streampos new_start, streampos new_end) { - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + new_start, false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)new_start, false); size_t new_size = new_end - new_start; size_t orig_size = orig_end - orig_start; diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index dd5d49cc59..621de7fe8a 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -307,7 +307,7 @@ reload_buffer() { // First, let's fill the codec's input buffer with as many packets as it'll // take: - int ret; + int ret = 0; while (_packet->data != nullptr) { ret = avcodec_send_packet(_audio_ctx, _packet); diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index b3fabdee6c..27f226a6cc 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -400,7 +400,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat; - for (size_t j = 0; j < orig_a->get_num_columns(); ++j) { + for (int j = 0; j < orig_a->get_num_columns(); ++j) { const GeomVertexColumn *column = orig_a->get_column(j); new_a->add_column(column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index dcdeeccc56..f46c8288f1 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1297,7 +1297,7 @@ set_size(int x, int y) { */ void CLP(GraphicsBuffer):: select_target_tex_page(int page) { - nassertv(page >= 0 && page < _fbo.size()); + nassertv(page >= 0 && (size_t)page < _fbo.size()); CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p(); @@ -1574,10 +1574,10 @@ close_buffer() { report_my_gl_errors(); // Delete the FBO itself. - for (int i = 0; i < _fbo.size(); ++i) { - glgsg->_glDeleteFramebuffers(1, &_fbo[i]); + if (!_fbo.empty()) { + glgsg->_glDeleteFramebuffers(_fbo.size(), _fbo.data()); + _fbo.clear(); } - _fbo.clear(); report_my_gl_errors(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index b6790e4931..6958c4ff9a 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -4374,9 +4374,9 @@ unbind_buffers() { if (_current_vertex_buffers.size() > 1 && _supports_multi_bind) { _glBindVertexBuffers(0, _current_vertex_buffers.size(), nullptr, nullptr, nullptr); } else { - for (int i = 0; i < _current_vertex_buffers.size(); ++i) { + for (size_t i = 0; i < _current_vertex_buffers.size(); ++i) { if (_current_vertex_buffers[i] != 0) { - _glBindVertexBuffer(i, 0, 0, 0); + _glBindVertexBuffer((GLuint)i, 0, 0, 0); } } } @@ -13309,7 +13309,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { GLint wrap_u, wrap_v, wrap_w; GLint minfilter, magfilter; + +#ifndef OPENGLES GLfloat border_color[4]; +#endif #ifdef OPENGLES if (true) { @@ -13803,11 +13806,13 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { tex->set_wrap_u(get_panda_wrap_mode(wrap_u)); tex->set_wrap_v(get_panda_wrap_mode(wrap_v)); tex->set_wrap_w(get_panda_wrap_mode(wrap_w)); - tex->set_border_color(LColor(border_color[0], border_color[1], - border_color[2], border_color[3])); - tex->set_minfilter(get_panda_filter_type(minfilter)); //tex->set_magfilter(get_panda_filter_type(magfilter)); + +#ifndef OPENGLES + tex->set_border_color(LColor(border_color[0], border_color[1], + border_color[2], border_color[3])); +#endif } PTA_uchar image; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 103ebce74f..ac9b28e784 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -352,7 +352,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext StorageBlock block; block._name = InternalName::make(block_name_cstr); block._binding_index = values[0]; - block._min_size = values[1]; + block._min_size = (GLuint)values[1]; _storage_blocks.push_back(block); } } @@ -681,6 +681,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b break; } + (void)numeric_type; + (void)contents; + (void)num_components; // GeomVertexColumn column(InternalName::make(name_buffer), // num_components, numeric_type, contents, offsets[ui], 4, param_size, // astrides[ui]); block_format.add_column(column); @@ -1986,7 +1989,7 @@ issue_parameters(int altered) { if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) { // If we have an osg_FrameNumber input, set it now. - if ((altered | Shader::SSD_frame) != 0 && _frame_number_loc >= 0) { + if ((altered & Shader::SSD_frame) != 0 && _frame_number_loc >= 0) { _glgsg->_glUniform1i(_frame_number_loc, _frame_number); } @@ -2169,7 +2172,7 @@ update_transform_table(const TransformTable *table) { #endif } } - for (; i < _transform_table_size; ++i) { + for (; i < (size_t)_transform_table_size; ++i) { matrices[i] = LMatrix4f::ident_mat(); } @@ -2237,7 +2240,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Use experimental new separated formatbinding state. const GeomVertexDataPipelineReader *data_reader = _glgsg->_data_reader; - for (int ai = 0; ai < data_reader->get_num_arrays(); ++ai) { + for (size_t ai = 0; ai < data_reader->get_num_arrays(); ++ai) { array_reader = data_reader->get_array_reader(ai); // Make sure the vertex buffer is up-to-date. @@ -2294,7 +2297,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { int start, stride, num_values; size_t nvarying = _shader->_var_spec.size(); - GLuint max_p = 0; + GLint max_p = 0; for (size_t i = 0; i < nvarying; ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; @@ -2312,7 +2315,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } } - GLuint p = bind._id._seqno; + GLint p = bind._id._seqno; max_p = max(max_p, p + 1); // Don't apply vertex colors if they are disabled with a ColorAttrib. @@ -2401,7 +2404,7 @@ disable_shader_texture_bindings() { DO_PSTATS_STUFF(_glgsg->_texture_state_pcollector.add_level(1)); - for (int i = 0; i < _shader->_tex_spec.size(); ++i) { + for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { #ifndef OPENGLES // Check if bindless was used, if so, there's nothing to unbind. if (_glgsg->_supports_bindless_texture) { diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index be71b93436..91130e9224 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -99,7 +99,7 @@ private: struct StorageBlock { CPT(InternalName) _name; GLuint _binding_index; - GLint _min_size; + GLuint _min_size; }; typedef pvector StorageBlocks; StorageBlocks _storage_blocks; diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index f6550a0de3..3e37496bad 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -145,7 +145,7 @@ make_adjacency() const { // Add the actual vertices in the strip. adj->add_vertex(v0); - int v1; + int v1 = v0; while (vi < end) { v1 = from.get_vertex(vi++); adj->add_vertex(v1); diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 2a82eef81f..578e99d805 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -557,9 +557,7 @@ get_format_string(bool pad) const { int fi = 0; int offset = 0; - for (int ci = 0; ci < get_num_columns(); ++ci) { - const GeomVertexColumn *column = get_column(ci); - + for (const GeomVertexColumn *column : _columns) { if (offset < column->get_start()) { // Add padding bytes to fill the gap. int pad = column->get_start() - offset; diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index dd1d800309..bfea5a10ef 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -677,7 +677,7 @@ has_column(const InternalName *name) const { /** * */ -INLINE int GeomVertexDataPipelineBase:: +INLINE size_t GeomVertexDataPipelineBase:: get_num_arrays() const { return _cdata->_arrays.size(); } @@ -686,8 +686,8 @@ get_num_arrays() const { * */ INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase:: -get_array(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), nullptr); +get_array(size_t i) const { + nassertr(i < _cdata->_arrays.size(), nullptr); return _cdata->_arrays[i].get_read_pointer(); } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index e87e573552..5e5fa7a1d4 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -344,7 +344,7 @@ void GeomVertexData:: clear_rows() { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); - nassertv(cdata->_format->get_num_arrays() == (int)cdata->_arrays.size()); + nassertv(cdata->_format->get_num_arrays() == cdata->_arrays.size()); Arrays::iterator ai; for (ai = cdata->_arrays.begin(); @@ -2243,7 +2243,7 @@ get_num_bytes() const { */ int GeomVertexDataPipelineReader:: get_num_rows() const { - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0); nassertr(_got_array_readers, 0); if (_cdata->_format->get_num_arrays() == 0) { @@ -2395,7 +2395,7 @@ make_array_readers() { */ int GeomVertexDataPipelineWriter:: get_num_rows() const { - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0); nassertr(_got_array_writers, 0); if (_cdata->_format->get_num_arrays() == 0) { @@ -2414,7 +2414,7 @@ get_num_rows() const { bool GeomVertexDataPipelineWriter:: set_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; @@ -2510,7 +2510,7 @@ set_num_rows(int n) { bool GeomVertexDataPipelineWriter:: unclean_set_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; @@ -2537,7 +2537,7 @@ unclean_set_num_rows(int n) { bool GeomVertexDataPipelineWriter:: reserve_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 52d177e5e2..9b861c1cbc 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -419,8 +419,8 @@ public: INLINE bool has_column(const InternalName *name) const; INLINE UsageHint get_usage_hint() const; - INLINE int get_num_arrays() const; - INLINE CPT(GeomVertexArrayData) get_array(int i) const; + INLINE size_t get_num_arrays() const; + INLINE CPT(GeomVertexArrayData) get_array(size_t i) const; INLINE const TransformTable *get_transform_table() const; INLINE CPT(TransformBlendTable) get_transform_blend_table() const; INLINE const SliderTable *get_slider_table() const; diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index 00bd42a33f..c1a4f96051 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -102,7 +102,7 @@ set_vertex_column(int array, const GeomVertexColumn *column, #ifndef NDEBUG _array = -1; _packer = nullptr; - nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); + nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false); #endif _array = array; diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index a433bef9e2..eaae2603ac 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -133,7 +133,7 @@ set_vertex_column(int array, const GeomVertexColumn *column, #ifndef NDEBUG _array = -1; _packer = nullptr; - nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); + nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false); #endif _array = array; diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index b5e9e78489..5914fd3598 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2652,7 +2652,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } char pragma[64]; - int nread = 0; + size_t nread = 0; // What kind of directive is it? if (strcmp(directive, "pragma") == 0 && sscanf(line.c_str(), " # pragma %63s", pragma) == 1) { @@ -2661,13 +2661,13 @@ r_preprocess_source(ostream &out, const Filename &fn, Filename incfn, source_dir; { char incfile[2048]; - if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %n", incfile, &nread) == 1 + if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %zn", incfile, &nread) == 1 && nread == line.size()) { // A regular include, with double quotes. Probably a local file. source_dir = full_fn.get_dirname(); incfn = incfile; - } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %n", incfile, &nread) == 1 + } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %zn", incfile, &nread) == 1 && nread == line.size()) { // Angled includes are also OK, but we don't search in the directory // of the source file. @@ -2696,7 +2696,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (strcmp(pragma, "once") == 0) { // Do a stricter syntax check, just to be extra safe. - if (sscanf(line.c_str(), " # pragma%*[ \t]once %n", &nread) != 0 || + if (sscanf(line.c_str(), " # pragma%*[ \t]once %zn", &nread) != 0 || nread != line.size()) { shader_cat.error() << "Malformed #pragma once at line " << lineno @@ -2788,7 +2788,7 @@ r_preprocess_source(ostream &out, const Filename &fn, Filename incfn; { char incfile[2048]; - if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %n", incfile, &nread) != 1 + if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %zn", incfile, &nread) != 1 || nread != line.size()) { // Couldn't parse it. shader_cat.error() @@ -2815,7 +2815,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (ext_google_line > 0 && strcmp(directive, "line") == 0) { // It's a #line directive. See if it uses a string instead of number. char filestr[2048]; - if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %n", &lineno, filestr, &nread) == 2 + if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %zn", &lineno, filestr, &nread) == 2 && nread == line.size()) { // Warn about extension use if requested. if (ext_google_line == 1) { diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 1ebeec18db..5918210fdc 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -4224,7 +4224,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } // See: https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - uint32_t gl_type, type_size, gl_format, internal_format, gl_base_format, + uint32_t gl_type, /*type_size,*/ gl_format, internal_format, gl_base_format, width, height, depth, num_array_elements, num_faces, num_mipmap_levels, kvdata_size; @@ -4232,7 +4232,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) if (ktx.get_uint32() == 0x04030201) { big_endian = false; gl_type = ktx.get_uint32(); - type_size = ktx.get_uint32(); + /*type_size = */ktx.get_uint32(); gl_format = ktx.get_uint32(); internal_format = ktx.get_uint32(); gl_base_format = ktx.get_uint32(); @@ -4246,7 +4246,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } else { big_endian = true; gl_type = ktx.get_be_uint32(); - type_size = ktx.get_be_uint32(); + /*type_size = */ktx.get_be_uint32(); gl_format = ktx.get_be_uint32(); internal_format = ktx.get_be_uint32(); gl_base_format = ktx.get_be_uint32(); diff --git a/panda/src/linmath/lsimpleMatrix.I b/panda/src/linmath/lsimpleMatrix.I index 7ce8b4ed69..6d322bfb75 100644 --- a/panda/src/linmath/lsimpleMatrix.I +++ b/panda/src/linmath/lsimpleMatrix.I @@ -11,33 +11,6 @@ * @date 2011-12-15 */ -/** - * - */ -template -INLINE LSimpleMatrix:: -LSimpleMatrix() { - // No default initialization. -} - -/** - * - */ -template -INLINE LSimpleMatrix:: -LSimpleMatrix(const LSimpleMatrix ©) { - memcpy(_array, copy._array, sizeof(_array)); -} - -/** - * - */ -template -INLINE void LSimpleMatrix:: -operator = (const LSimpleMatrix ©) { - memcpy(_array, copy._array, sizeof(_array)); -} - /** * */ diff --git a/panda/src/linmath/lsimpleMatrix.h b/panda/src/linmath/lsimpleMatrix.h index 3228caf5bb..faeecd9516 100644 --- a/panda/src/linmath/lsimpleMatrix.h +++ b/panda/src/linmath/lsimpleMatrix.h @@ -28,9 +28,6 @@ template class LSimpleMatrix { public: - INLINE LSimpleMatrix(); - INLINE LSimpleMatrix(const LSimpleMatrix ©); - INLINE void operator = (const LSimpleMatrix ©); INLINE const FloatType &operator () (int row, int col) const; INLINE FloatType &operator () (int row, int col); INLINE const FloatType &operator () (int col) const; diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 4ca05ea17a..c92602ac34 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -221,7 +221,7 @@ process_geom(const Geom *geom) { CPT(GeomVertexData) vData = geom->get_vertex_data(); - for (int i = 0; i < geom->get_num_primitives(); ++i) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { process_primitive(geom->get_primitive(i), vData); } } @@ -308,7 +308,7 @@ analyze(const Geom *geom) { return; } - for (int i = 0; i < geom->get_num_primitives(); ++i) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { analyze(geom->get_primitive(i)); } } diff --git a/panda/src/parametrics/nurbsSurfaceResult.cxx b/panda/src/parametrics/nurbsSurfaceResult.cxx index e1bfccb168..86b6f6615f 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.cxx +++ b/panda/src/parametrics/nurbsSurfaceResult.cxx @@ -62,10 +62,10 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, // Create four geometry matrices from our (up to) sixteen involved // vertices. LMatrix4 geom_x, geom_y, geom_z, geom_w; - memset(&geom_x, 0, sizeof(geom_x)); - memset(&geom_y, 0, sizeof(geom_y)); - memset(&geom_z, 0, sizeof(geom_z)); - memset(&geom_w, 0, sizeof(geom_w)); + geom_x.fill(0); + geom_y.fill(0); + geom_z.fill(0); + geom_w.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { @@ -178,7 +178,7 @@ eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) int vn = _v_basis.get_vertex_index(vi); LMatrix4 geom; - memset(&geom, 0, sizeof(geom)); + geom.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { @@ -223,7 +223,7 @@ eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d for (int n = 0; n < num_values; n++) { LMatrix4 geom; - memset(&geom, 0, sizeof(geom)); + geom.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index 9aa9c77e52..cdd340c989 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -294,7 +294,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { GeomVertexReader texcoord(geom->get_vertex_data(), InternalName::get_texcoord()); if (texcoord.has_column()) { - for (int pi = 0; pi < geom->get_num_primitives(); ++pi) { + for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) { primitive = geom->get_primitive(pi); for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) { int vert = primitive->get_vertex(vi); @@ -338,7 +338,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { GeomVertexReader vertex(geom->get_vertex_data(), InternalName::get_vertex()); if (vertex.has_column()) { - for (int pi = 0; pi < geom->get_num_primitives(); ++pi) { + for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) { primitive = geom->get_primitive(pi); for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) { int vert = primitive->get_vertex(vi); diff --git a/panda/src/pgraph/camera.I b/panda/src/pgraph/camera.I index 1ab7bc2e41..7d32f433d3 100644 --- a/panda/src/pgraph/camera.I +++ b/panda/src/pgraph/camera.I @@ -64,7 +64,7 @@ get_num_display_regions() const { */ INLINE DisplayRegion *Camera:: get_display_region(size_t n) const { - nassertr(n < (int)_display_regions.size(), nullptr); + nassertr(n < _display_regions.size(), nullptr); return _display_regions[n]; } diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index 6e4d30955e..cfc023b528 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -1479,7 +1479,7 @@ remove_unused_vertices(const GeomVertexData *vdata) { PT(GeomVertexData) new_vdata = new GeomVertexData(*vdata); new_vdata->unclean_set_num_rows(new_num_vertices); - int num_arrays = vdata->get_num_arrays(); + size_t num_arrays = vdata->get_num_arrays(); nassertv(num_arrays == new_vdata->get_num_arrays()); GeomVertexDataPipelineReader reader(vdata, current_thread); @@ -1487,7 +1487,7 @@ remove_unused_vertices(const GeomVertexData *vdata) { GeomVertexDataPipelineWriter writer(new_vdata, true, current_thread); writer.check_array_writers(); - for (int a = 0; a < num_arrays; ++a) { + for (size_t a = 0; a < num_arrays; ++a) { const GeomVertexArrayDataHandle *array_reader = reader.get_array_reader(a); GeomVertexArrayDataHandle *array_writer = writer.get_array_writer(a); diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index dceb4abf4b..22d0b32259 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -261,7 +261,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { rs->get_attrib_def(la); bool have_ambient = false; - for (int i = 0; i < la->get_num_on_lights(); ++i) { + for (size_t i = 0; i < la->get_num_on_lights(); ++i) { NodePath np = la->get_on_light(i); nassertv(!np.is_empty()); PandaNode *node = np.node(); diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 79c1829374..9cca9f6d2f 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -112,7 +112,7 @@ add_impact(const LPoint3 &offset, a = a.cross(b); PN_stdfloat angle = a.length(); if (angle) { - LRotation torque; + LRotation torque(0, 0, 0, 0); PN_stdfloat spin = force.length()*0.1; // todo: this should account for // impact distance and mass. a.normalize(); diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 763dc3a8d6..a3633226bc 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -94,7 +94,7 @@ cycle() { pvector< PT(CycleData) > saved_cdatas; { ReMutexHolder cycle_holder(_cycle_lock); - int prev_seq, next_seq; + unsigned int prev_seq, next_seq; PipelineCyclerLinks prev_dirty; { // We can't hold the lock protecting the linked lists during the cycling diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index abe2845add..57b9671d1a 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -1726,35 +1726,32 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 // Now determine the minmax. PN_float32 min_x, min_y, min_z, max_x, max_y, max_z; - bool got_point = false; if (points_only) { - LPoint3f points[4] = { + const LPoint3f points[4] = { p0 * rinv, p1 * rinv, p2 * rinv, p3 * rinv, }; - for (int i = 0; i < 4; ++i) { - const LPoint3f &point = points[i]; - if (!got_point) { - min_x = point[0]; - min_y = point[1]; - min_z = point[2]; - max_x = point[0]; - max_y = point[1]; - max_z = point[2]; - got_point = true; - } else { - min_x = min(min_x, point[0]); - min_y = min(min_y, point[1]); - min_z = min(min_z, point[2]); - max_x = max(max_x, point[0]); - max_y = max(max_y, point[1]); - max_z = max(max_z, point[2]); - } - } + const LPoint3f &point = points[0]; + min_x = point[0]; + min_y = point[1]; + min_z = point[2]; + max_x = point[0]; + max_y = point[1]; + max_z = point[2]; + for (int i = 1; i < 4; ++i) { + const LPoint3f &point = points[i]; + min_x = min(min_x, point[0]); + min_y = min(min_y, point[1]); + min_z = min(min_z, point[2]); + max_x = max(max_x, point[0]); + max_y = max(max_y, point[1]); + max_z = max(max_z, point[2]); + } } else { + bool got_point = false; for (int yi = 0; yi < _y_size; ++yi) { for (int xi = 0; xi < _x_size; ++xi) { if (!has_point(xi, yi)) { @@ -1780,6 +1777,14 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 } } } + if (!got_point) { + min_x = 0.0f; + min_y = 0.0f; + min_z = 0.0f; + max_x = 0.0f; + max_y = 0.0f; + max_z = 0.0f; + } } PT(BoundingHexahedron) bounds; diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index a332d693dc..ca1f356c48 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -40,7 +40,7 @@ typedef unsigned char gray; struct pixel { PUBLISHED: - pixel() { } + pixel() = default; pixel(gray fill) : r(fill), g(fill), b(fill) { } pixel(gray r, gray g, gray b) : r(r), g(g), b(b) { } diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 18fc389150..a50ae370ae 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -721,8 +721,8 @@ get_pixel( istream *ifp, pixel *dest, int Size, gray *alpha_p) { Red = getbyte( ifp ); if ( Size == 32 ) Alpha = getbyte( ifp ); - else - Alpha = 0; + else + Alpha = 0; l = 0; break; diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index a729a22fa8..710d803e3e 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -25,20 +25,6 @@ PStatCollector(PStatClient *client, int index) : { } -/** - * Creates an invalid PStatCollector. Any attempt to use this collector will - * crash messily. - * - * You can reassign it to a different, valid one later. - */ -INLINE PStatCollector:: -PStatCollector() : - _client(nullptr), - _index(0), - _level(0.0f) -{ -} - /** * Creates a new PStatCollector, ready to start accumulating data. The name * of the collector uniquely identifies it among the other collectors; if two diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index a007faa61c..aeb74f7cdb 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -47,7 +47,7 @@ private: INLINE PStatCollector(PStatClient *client, int index); public: - INLINE PStatCollector(); + PStatCollector() = default; PUBLISHED: INLINE explicit PStatCollector(const std::string &name, @@ -99,9 +99,9 @@ PUBLISHED: INLINE int get_index() const; private: - PStatClient *_client; - int _index; - double _level; + PStatClient *_client = nullptr; + int _index = 0; + double _level = 0.0; friend class PStatClient; diff --git a/panda/src/putil/bitArray.cxx b/panda/src/putil/bitArray.cxx index 42f0d47259..2ba077e0c1 100644 --- a/panda/src/putil/bitArray.cxx +++ b/panda/src/putil/bitArray.cxx @@ -87,7 +87,7 @@ is_all_on() const { */ bool BitArray:: has_any_of(int low_bit, int size) const { - if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { + if ((size_t)(low_bit + size) > get_num_bits()) { // This range touches the highest bits. if (_highest_bits) { return true; @@ -97,7 +97,7 @@ has_any_of(int low_bit, int size) const { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // This range is entirely among the highest bits. return (_highest_bits != 0); } @@ -126,7 +126,7 @@ has_any_of(int low_bit, int size) const { size -= num_bits_per_word; ++w; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // Now we're up to the highest bits. return (_highest_bits != 0); } @@ -140,7 +140,7 @@ has_any_of(int low_bit, int size) const { */ bool BitArray:: has_all_of(int low_bit, int size) const { - if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { + if ((size_t)(low_bit + size) > get_num_bits()) { // This range touches the highest bits. if (!_highest_bits) { return false; @@ -150,7 +150,7 @@ has_all_of(int low_bit, int size) const { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // This range is entirely among the highest bits. return (_highest_bits != 0); } @@ -179,7 +179,7 @@ has_all_of(int low_bit, int size) const { size -= num_bits_per_word; ++w; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // Now we're up to the highest bits. return (_highest_bits != 0); } @@ -196,7 +196,7 @@ set_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words() && _highest_bits) { + if (w >= (int)get_num_words() && _highest_bits) { // All the highest bits are already on. return; } @@ -229,7 +229,7 @@ set_range(int low_bit, int size) { size -= num_bits_per_word; ++w; - if (w >= get_num_words() && _highest_bits) { + if (w >= (int)get_num_words() && _highest_bits) { // All the highest bits are already on. normalize(); return; @@ -246,7 +246,7 @@ clear_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words() && !_highest_bits) { + if (w >= (int)get_num_words() && !_highest_bits) { // All the highest bits are already off. return; } @@ -279,7 +279,7 @@ clear_range(int low_bit, int size) { size -= num_bits_per_word; ++w; - if (w >= get_num_words() && !_highest_bits) { + if (w >= (int)get_num_words() && !_highest_bits) { // All the highest bits are already off. normalize(); return; diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 35ede588a4..cc400a14fb 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -214,8 +214,8 @@ has_any_of(int low_bit, int size) const { } else { int hi_portion = low_bit + size - half_bits; int lo_portion = size - hi_portion; - return (_hi.has_any_of(0, hi_portion) << lo_portion) || - _lo.has_any_of(low_bit, lo_portion); + return _hi.has_any_of(0, hi_portion) + || _lo.has_any_of(low_bit, lo_portion); } } @@ -232,8 +232,8 @@ has_all_of(int low_bit, int size) const { } else { int hi_portion = low_bit + size - half_bits; int lo_portion = size - hi_portion; - return (_hi.has_all_of(0, hi_portion) << lo_portion) && - _lo.has_all_of(low_bit, lo_portion); + return _hi.has_all_of(0, hi_portion) + && _lo.has_all_of(low_bit, lo_portion); } } diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index eeba7183dc..341028d068 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -15,20 +15,6 @@ #include "indent.h" #include "config_putil.h" -/** - * - */ -FactoryBase:: -FactoryBase() { -} - -/** - * - */ -FactoryBase:: -~FactoryBase() { -} - /** * Attempts to create a new instance of some class of the indicated type, or * some derivative if necessary. If an instance of the exact type cannot be @@ -145,7 +131,7 @@ register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) { /** * Returns the number of different types the Factory knows how to create. */ -int FactoryBase:: +size_t FactoryBase:: get_num_types() const { return _creators.size(); } @@ -156,8 +142,8 @@ get_num_types() const { * Normally you wouldn't need to traverse the list of the Factory's types. */ TypeHandle FactoryBase:: -get_type(int n) const { - nassertr(n >= 0 && n < get_num_types(), TypeHandle::none()); +get_type(size_t n) const { + nassertr(n < get_num_types(), TypeHandle::none()); Creators::const_iterator ci; for (ci = _creators.begin(); ci != _creators.end(); ++ci) { if (n == 0) { @@ -193,7 +179,7 @@ add_preferred(TypeHandle handle) { /** * Returns the number of types added to the preferred-type list. */ -int FactoryBase:: +size_t FactoryBase:: get_num_preferred() const { return _preferred.size(); } @@ -202,8 +188,8 @@ get_num_preferred() const { * Returns the nth type added to the preferred-type list. */ TypeHandle FactoryBase:: -get_preferred(int n) const { - nassertr(n >= 0 && n < get_num_preferred(), TypeHandle::none()); +get_preferred(size_t n) const { + nassertr(n < get_num_preferred(), TypeHandle::none()); return _preferred[n]; } @@ -219,21 +205,6 @@ write_types(std::ostream &out, int indent_level) const { } } - -/** - * Don't copy Factories. - */ -FactoryBase:: -FactoryBase(const FactoryBase &) { -} - -/** - * Don't copy Factories. - */ -void FactoryBase:: -operator = (const FactoryBase &) { -} - /** * Attempts to create an instance of the exact type requested by the given * handle. Returns the new instance created, or NULL if the instance could @@ -262,9 +233,7 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { // First, walk through the established preferred list. Maybe one of these // qualifies. - Preferred::const_iterator pi; - for (pi = _preferred.begin(); pi != _preferred.end(); ++pi) { - TypeHandle ptype = (*pi); + for (TypeHandle ptype : _preferred) { if (ptype.is_derived_from(handle)) { TypedObject *object = make_instance_exact(ptype, params); if (object != nullptr) { diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 7ef256f1a8..65617f254b 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -39,8 +39,11 @@ public: // public interface public: - FactoryBase(); - ~FactoryBase(); + FactoryBase() = default; + FactoryBase(const FactoryBase ©) = delete; + ~FactoryBase() = default; + + FactoryBase &operator = (const FactoryBase ©) = delete; TypedObject *make_instance(TypeHandle handle, const FactoryParams ¶ms); @@ -58,21 +61,17 @@ public: void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = nullptr); - int get_num_types() const; - TypeHandle get_type(int n) const; + size_t get_num_types() const; + TypeHandle get_type(size_t n) const; void clear_preferred(); void add_preferred(TypeHandle handle); - int get_num_preferred() const; - TypeHandle get_preferred(int n) const; + size_t get_num_preferred() const; + TypeHandle get_preferred(size_t n) const; void write_types(std::ostream &out, int indent_level = 0) const; private: - // These are private; we shouldn't be copy-constructing Factories. - FactoryBase(const FactoryBase ©); - void operator = (const FactoryBase ©); - // internal utility functions TypedObject *make_instance_exact(TypeHandle handle, FactoryParams params); TypedObject *make_instance_more_specific(TypeHandle handle, diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index b62406861a..0f71e62969 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -13,45 +13,6 @@ #include "pnotify.h" -/** - * - */ -INLINE FactoryParams:: -FactoryParams() : _user_data(nullptr) { -} - -/** - * - */ -INLINE FactoryParams:: -FactoryParams(const FactoryParams ©) : - _params(copy._params), - _user_data(copy._user_data) {} - -/** - * - */ -INLINE FactoryParams:: -~FactoryParams() { -} - -/** - * - */ -INLINE FactoryParams:: -FactoryParams(FactoryParams &&from) noexcept : - _params(std::move(from._params)), - _user_data(from._user_data) {} - -/** - * - */ -INLINE void FactoryParams:: -operator = (FactoryParams &&from) noexcept { - _params = std::move(from._params); - _user_data = from._user_data; -} - /** * Returns the custom pointer that was associated with the factory function. */ diff --git a/panda/src/putil/factoryParams.h b/panda/src/putil/factoryParams.h index 3f987e7f66..b76dc81e84 100644 --- a/panda/src/putil/factoryParams.h +++ b/panda/src/putil/factoryParams.h @@ -35,12 +35,12 @@ */ class EXPCL_PANDA_PUTIL FactoryParams { public: - INLINE FactoryParams(); - INLINE FactoryParams(const FactoryParams ©); - INLINE FactoryParams(FactoryParams &&from) noexcept; - INLINE ~FactoryParams(); + FactoryParams() = default; + FactoryParams(const FactoryParams ©) = default; + FactoryParams(FactoryParams &&from) noexcept = default; + ~FactoryParams() = default; - INLINE void operator = (FactoryParams &&from) noexcept; + FactoryParams &operator = (FactoryParams &&from) noexcept = default; void add_param(FactoryParam *param); void clear(); @@ -56,7 +56,7 @@ private: typedef pvector< PT(TypedReferenceCount) > Params; Params _params; - void *_user_data; + void *_user_data = nullptr; friend class FactoryBase; }; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 3717405893..8f49433ebd 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -2251,10 +2251,10 @@ do_issue_texture() { // The following special cases are handled inline, rather than relying // on the above wrap function pointers. - if (wrap_u && SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { + if (wrap_u == SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { texture_def->tex_minfilter_func = apply_wrap_border_color_minfilter; texture_def->tex_magfilter_func = apply_wrap_border_color_magfilter; - } else if (wrap_u && SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) { + } else if (wrap_u == SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) { texture_def->tex_minfilter_func = apply_wrap_clamp_minfilter; texture_def->tex_magfilter_func = apply_wrap_clamp_magfilter; } diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index daa035dc75..72f3c1ae11 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -14,7 +14,7 @@ int error, derror; int x1, dxdy_min, dxdy_max; /* warning: x2 is multiplied by 2^16 */ - UNUSED int x2, dx2dy2; + int x2, dx2dy2; #ifdef INTERP_Z int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0; @@ -348,10 +348,10 @@ int n; #ifdef INTERP_Z ZPOINT *pz; - UNUSED unsigned int z,zz; + unsigned int z,zz; #endif #ifdef INTERP_RGB - UNUSED unsigned int or1,og1,ob1,oa1; + unsigned int or1,og1,ob1,oa1; #endif #ifdef INTERP_ST unsigned int s,t; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 49c4550b4a..0d9db0df0f 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -1,3 +1,9 @@ +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + static void FNAME(white_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) @@ -229,7 +235,7 @@ FNAME(smooth_textured) (ZBuffer *zb, c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - if (c0 == 0xffffffff) { \ + if (c0 == 0xffffffffu) { \ /* Actually, it's a white triangle. */ \ FNAME(white_textured)(zb, p0, p1, p2); \ return; \ @@ -537,13 +543,13 @@ FNAME(smooth_perspective) (ZBuffer *zb, #define EARLY_OUT() \ { \ - int c0, c1, c2; \ + unsigned int c0, c1, c2; \ c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \ c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \ c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - if (c0 == 0xffffffff) { \ + if (c0 == 0xffffffffu) { \ /* Actually, it's a white triangle. */ \ FNAME(white_perspective)(zb, p0, p1, p2); \ return; \ @@ -1008,3 +1014,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, #undef INTERP_MIPMAP #undef CALC_MIPMAP_LEVEL #undef ZB_LOOKUP_TEXTURE + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 0187139828..af1e9de489 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -174,7 +174,7 @@ move_pointer(int device, int x, int y) { return true; } else { // Move a raw mouse. - if ((device < 1)||(device >= _input_devices.size())) { + if (device < 1 || (size_t)device >= _input_devices.size()) { return false; } _input_devices[device].set_pointer_in_window(x, y); diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 7278a32dc9..7044409ca5 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -649,7 +649,7 @@ process_f_node(vector_string &words) { _f_given = true; bool all_vn = true; - int non_vn_index = -1; + //int non_vn_index = -1; pvector verts; verts.reserve(words.size() - 1); @@ -658,7 +658,7 @@ process_f_node(vector_string &words) { verts.push_back(entry); if (entry._vni == 0) { all_vn = false; - non_vn_index = i; + //non_vn_index = i; } } @@ -706,7 +706,7 @@ process_f_node(vector_string &words) { } if (_current_vertex_data->_prim->get_num_vertices() + 3 * num_tris > egg_max_indices || - _current_vertex_data->_entries.size() + verts.size() > egg_max_vertices) { + _current_vertex_data->_entries.size() + verts.size() > (size_t)egg_max_vertices) { // We'll exceed our specified limit with these triangles; start a new // Geom. _current_vertex_data->close_geom(this); diff --git a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt index cc79d45379..8022d21f4b 100644 --- a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt @@ -2883,7 +2883,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/vrml/vrmlLexer.lxx b/pandatool/src/vrml/vrmlLexer.lxx index fb16b30c40..6b03b79894 100644 --- a/pandatool/src/vrml/vrmlLexer.lxx +++ b/pandatool/src/vrml/vrmlLexer.lxx @@ -159,7 +159,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/xfile/xLexer.cxx.prebuilt b/pandatool/src/xfile/xLexer.cxx.prebuilt index b808f143ee..92eb941a15 100644 --- a/pandatool/src/xfile/xLexer.cxx.prebuilt +++ b/pandatool/src/xfile/xLexer.cxx.prebuilt @@ -794,7 +794,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/xfile/xLexer.lxx b/pandatool/src/xfile/xLexer.lxx index c20ca309d2..7a5aac98a1 100644 --- a/pandatool/src/xfile/xLexer.lxx +++ b/pandatool/src/xfile/xLexer.lxx @@ -150,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ }