From b88bd9970464ebda498e96bab08f7403757da7fa Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Jun 2018 11:09:26 +0200 Subject: [PATCH] Various compiler warning fixes --- .../interfaceMakerPythonNative.cxx | 20 ------------------- panda/src/char/characterSlider.h | 1 + panda/src/display/nativeWindowHandle.h | 2 +- panda/src/egg/eggCompositePrimitive.cxx | 8 ++++---- panda/src/egg/eggPrimitive.cxx | 8 +++----- panda/src/egg/eggTriangleFan.cxx | 2 +- panda/src/egg2pg/eggSaver.cxx | 4 ++-- panda/src/event/asyncTaskSequence.I | 2 +- panda/src/event/asyncTaskSequence.h | 4 ++-- .../glstuff/glGraphicsStateGuardian_src.cxx | 2 +- .../src/glstuff/glGraphicsStateGuardian_src.h | 2 +- panda/src/grutil/meshDrawer.cxx | 2 +- panda/src/grutil/movieTexture.cxx | 11 ++++++++++ panda/src/grutil/movieTexture.h | 3 +++ panda/src/movies/dr_flac.h | 2 ++ panda/src/pgraph/geomTransformer.cxx | 2 +- panda/src/pgraph/nodePathCollection.cxx | 6 +++--- panda/src/pgraph/nodePathCollection.h | 4 ++-- panda/src/pgraphnodes/shaderGenerator.cxx | 5 +++++ panda/src/text/textAssembler.cxx | 4 ++-- panda/src/tinydisplay/ztriangle.h | 2 +- panda/src/tinydisplay/ztriangle_two.h | 14 ++++++------- 22 files changed, 55 insertions(+), 55 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 6c652bb806..c040f0dc6c 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -103,11 +103,6 @@ RenameSet methodRenameDictionary[] = { { nullptr, nullptr, -1 } }; -RenameSet classRenameDictionary[] = { - // No longer used, now empty. - { nullptr, nullptr, -1 } -}; - const char *pythonKeywords[] = { "and", "as", @@ -193,12 +188,6 @@ classNameFromCppName(const std::string &cppName, bool mangle) { } } - for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { - if (cppName == classRenameDictionary[x]._from) { - className = classRenameDictionary[x]._to; - } - } - if (className.empty()) { std::string text = "** ERROR ** Renaming class: " + cppName + " to empty string"; printf("%s", text.c_str()); @@ -253,15 +242,6 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, } } - if (className.size() > 0) { - string lookup_name = className + '.' + cppName; - for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { - if (lookup_name == methodRenameDictionary[x]._from) { - methodName = methodRenameDictionary[x]._to; - } - } - } - // # Mangle names that happen to be python keywords so they are not anymore methodName = checkKeyword(methodName); return methodName; diff --git a/panda/src/char/characterSlider.h b/panda/src/char/characterSlider.h index 3c347af12b..9871095afd 100644 --- a/panda/src/char/characterSlider.h +++ b/panda/src/char/characterSlider.h @@ -34,6 +34,7 @@ PUBLISHED: explicit CharacterSlider(PartGroup *parent, const std::string &name); virtual ~CharacterSlider(); +public: virtual PartGroup *make_copy() const; virtual bool update_internals(PartBundle *root, PartGroup *parent, diff --git a/panda/src/display/nativeWindowHandle.h b/panda/src/display/nativeWindowHandle.h index 1ee6fec43a..14bab98815 100644 --- a/panda/src/display/nativeWindowHandle.h +++ b/panda/src/display/nativeWindowHandle.h @@ -33,7 +33,7 @@ * This class exists for name scoping only. Don't use the constructor * directly; use one of the make_* methods. */ -class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle { +class EXPCL_PANDA_DISPLAY NativeWindowHandle final : public WindowHandle { private: INLINE NativeWindowHandle(); INLINE NativeWindowHandle(const NativeWindowHandle ©); diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index b42cb080c9..94c4b1d625 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -57,7 +57,7 @@ get_shading() const { if (!first_component->has_normal()) { first_component = this; } - for (int i = 1; i < get_num_components(); i++) { + for (size_t i = 1; i < get_num_components(); ++i) { const EggAttributes *component = get_component(i); if (!component->has_normal()) { component = this; @@ -74,7 +74,7 @@ get_shading() const { if (!first_component->has_color()) { first_component = this; } - for (int i = 1; i < get_num_components(); i++) { + for (size_t i = 1; i < get_num_components(); ++i) { const EggAttributes *component = get_component(i); if (!component->has_color()) { component = this; @@ -295,7 +295,7 @@ apply_last_attribute() { // The first component gets applied to the third vertex, and so on from // there. int num_lead_vertices = get_num_lead_vertices(); - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i + num_lead_vertices, component); } @@ -313,7 +313,7 @@ void EggCompositePrimitive:: apply_first_attribute() { // The first component gets applied to the first vertex, and so on from // there. - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i, component); } diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index ad0b464c30..ee35080416 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -227,7 +227,7 @@ get_shading() const { if (!first_vertex->has_normal()) { first_vertex = this; } - for (int i = 1; i < get_num_vertices(); i++) { + for (size_t i = 1; i < get_num_vertices(); ++i) { const EggAttributes *vertex = get_vertex(i); if (!vertex->has_normal()) { vertex = this; @@ -244,7 +244,7 @@ get_shading() const { if (!first_vertex->has_color()) { first_vertex = this; } - for (int i = 1; i < get_num_vertices(); i++) { + for (size_t i = 1; i < get_num_vertices(); ++i) { const EggAttributes *vertex = get_vertex(i); if (!vertex->has_color()) { vertex = this; @@ -461,9 +461,7 @@ apply_first_attribute() { void EggPrimitive:: post_apply_flat_attribute() { if (!empty()) { - for (int i = 0; i < (int)size(); i++) { - EggVertex *vertex = get_vertex(i); - + for (EggVertex *vertex : _vertices) { // Use set_normal() instead of copy_normal(), to avoid getting the // morphs--we don't want them here, since we're just putting a bogus // value on the normal anyway. diff --git a/panda/src/egg/eggTriangleFan.cxx b/panda/src/egg/eggTriangleFan.cxx index 30d441286a..6ad3b4f5ae 100644 --- a/panda/src/egg/eggTriangleFan.cxx +++ b/panda/src/egg/eggTriangleFan.cxx @@ -57,7 +57,7 @@ apply_first_attribute() { // In the case of a triangle fan, the first vertex of the fan is the common // vertex, so we consider the second vertex to be the key vertex of the // first triangle, and move from there. - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i + 1, component); } diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index b54b6df744..af70617e36 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -560,7 +560,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, // Get an arbitrary vector on the plane by taking the cross product // with any vector, as long as it is different. LVector3 vec1; - if (abs(normal[2]) > abs(normal[1])) { + if (std::fabs(normal[2]) > std::fabs(normal[1])) { vec1 = normal.cross(LVector3(0, 1, 0)); } else { vec1 = normal.cross(LVector3(0, 0, 1)); @@ -626,7 +626,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, // Also get an arbitrary vector perpendicular to the tube. LVector3 axis = point_b - point_a; LVector3 sideways; - if (abs(axis[2]) > abs(axis[1])) { + if (std::fabs(axis[2]) > std::fabs(axis[1])) { sideways = axis.cross(LVector3(0, 1, 0)); } else { sideways = axis.cross(LVector3(0, 0, 1)); diff --git a/panda/src/event/asyncTaskSequence.I b/panda/src/event/asyncTaskSequence.I index 28d94f2f75..332303df7a 100644 --- a/panda/src/event/asyncTaskSequence.I +++ b/panda/src/event/asyncTaskSequence.I @@ -34,7 +34,7 @@ get_repeat_count() const { * Returns the index of the task within the sequence that is currently being * executed (or that will be executed at the next epoch). */ -INLINE int AsyncTaskSequence:: +INLINE size_t AsyncTaskSequence:: get_current_task_index() const { return _task_index; } diff --git a/panda/src/event/asyncTaskSequence.h b/panda/src/event/asyncTaskSequence.h index 3d1c4cc450..096d1f6b88 100644 --- a/panda/src/event/asyncTaskSequence.h +++ b/panda/src/event/asyncTaskSequence.h @@ -39,7 +39,7 @@ PUBLISHED: INLINE void set_repeat_count(int repeat_count); INLINE int get_repeat_count() const; - INLINE int get_current_task_index() const; + INLINE size_t get_current_task_index() const; protected: virtual bool is_runnable(); @@ -51,7 +51,7 @@ private: void set_current_task(AsyncTask *task, bool clean_exit); int _repeat_count; - int _task_index; + size_t _task_index; PT(AsyncTask) _current_task; public: diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6c06ae0b6b..1e4c2bb530 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3007,7 +3007,7 @@ reset() { #ifndef OPENGLES_1 _enabled_vertex_attrib_arrays.clear(); - memset(_vertex_attrib_divisors, 0, sizeof(GLint) * 32); + memset(_vertex_attrib_divisors, 0, sizeof(GLuint) * 32); #endif // Dither is on by default in GL; let's turn it off diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 5c29d4bcad..c0f75a21d5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -661,7 +661,7 @@ protected: #ifndef OPENGLES_1 BitMask32 _enabled_vertex_attrib_arrays; - GLint _vertex_attrib_divisors[32]; + GLuint _vertex_attrib_divisors[32]; PT(Shader) _current_shader; ShaderContext *_current_shader_context; diff --git a/panda/src/grutil/meshDrawer.cxx b/panda/src/grutil/meshDrawer.cxx index a727c15ced..b87380d3b8 100644 --- a/panda/src/grutil/meshDrawer.cxx +++ b/panda/src/grutil/meshDrawer.cxx @@ -374,7 +374,7 @@ void MeshDrawer::geometry(NodePath draw_node) { CPT(GeomVertexData) v_data = geom->get_vertex_data(); GeomVertexReader *prim_vertex_reader = new GeomVertexReader(v_data, "vertex"); GeomVertexReader *prim_uv_reader = new GeomVertexReader(v_data, "texcoord"); - for(int k=0; k get_num_primitives(); k++) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim1 = geom->get_primitive(k); CPT(GeomPrimitive) _prim = prim1->decompose(); diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index c62eb23715..44f3d541d4 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -288,6 +288,17 @@ do_load_one(Texture::CData *cdata_tex, return false; } +/** + * Loading a static image into a MovieTexture is an error. + */ +bool MovieTexture:: +do_load_one(Texture::CData *cdata_tex, + const PfmFile &pfm, const std::string &name, int z, int n, + const LoaderOptions &options) { + grutil_cat.error() << "You cannot load a static image into a MovieTexture\n"; + return false; +} + /** * Called internally by do_reconsider_z_size() to allocate new memory in * _ram_images[0] for the new number of pages. diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index c1721f4320..1a49c885b1 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -102,6 +102,9 @@ protected: virtual bool do_load_one(Texture::CData *cdata, const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options); + virtual bool do_load_one(Texture::CData *cdata, + const PfmFile &pfm, const std::string &name, + int z, int n, const LoaderOptions &options); bool do_load_one(Texture::CData *cdata, PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, int z, const LoaderOptions &options); diff --git a/panda/src/movies/dr_flac.h b/panda/src/movies/dr_flac.h index fdac6a2f79..3d0b1cdd91 100644 --- a/panda/src/movies/dr_flac.h +++ b/panda/src/movies/dr_flac.h @@ -328,7 +328,9 @@ static drflac* drflac_open_memory(const void* data, size_t dataSize); #endif #ifdef __linux__ +#ifndef _BSD_SOURCE #define _BSD_SOURCE +#endif #include #endif diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index c77fc35e28..e21327b304 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -1242,7 +1242,7 @@ apply_collect_changes() { */ void GeomTransformer::NewCollectedData:: append_vdata(const GeomVertexData *vdata, int vertex_offset) { - for (int i = 0; i < vdata->get_num_arrays(); ++i) { + for (size_t i = 0; i < vdata->get_num_arrays(); ++i) { PT(GeomVertexArrayDataHandle) new_handle = _new_data->modify_array_handle(i); CPT(GeomVertexArrayDataHandle) old_handle = vdata->get_array_handle(i); size_t stride = (size_t)_new_format->get_array(i)->get_stride(); diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 68977a8b4b..8f29f07f22 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -188,8 +188,8 @@ get_path(int index) const { * get_path(), but it may be a more convenient way to access it. */ NodePath NodePathCollection:: -operator [] (int index) const { - nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath()); +operator [] (size_t index) const { + nassertr(index < _node_paths.size(), NodePath()); return _node_paths[index]; } @@ -198,7 +198,7 @@ operator [] (int index) const { * Returns the number of paths in the collection. This is the same thing as * get_num_paths(). */ -int NodePathCollection:: +size_t NodePathCollection:: size() const { return _node_paths.size(); } diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 64a16d63c3..6dd4e76b12 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -45,8 +45,8 @@ PUBLISHED: int get_num_paths() const; NodePath get_path(int index) const; MAKE_SEQ(get_paths, get_num_paths, get_path); - NodePath operator [] (int index) const; - int size() const; + NodePath operator [] (size_t index) const; + size_t size() const; INLINE void operator += (const NodePathCollection &other); INLINE NodePathCollection operator + (const NodePathCollection &other) const; diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index af4410aea2..bdca5406ce 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -404,6 +404,9 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { info._flags |= ShaderKey::TF_uses_last_saved_result; } break; + + default: + break; } // In fact, perhaps this stage should be disabled altogether? @@ -438,6 +441,8 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { skip = true; } break; + default: + break; } // We can't just drop a disabled slot from the list, since then the // indices for the texture stages will no longer match up. So we keep it, diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index c427be8c79..e59b83a100 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -2381,7 +2381,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, PT(Geom) geom = _glyph->get_geom(GeomEnums::UH_static); - int p, sp, s, e, i; + int sp, s, e, i; const GeomVertexData *vdata = geom->get_vertex_data(); CPT(RenderState) rs = _glyph->get_state()->compose(state); @@ -2398,7 +2398,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, // that we don't needlessly duplicate vertices into our output vertex data. VertexIndexMap vimap; - for (p = 0; p < geom->get_num_primitives(); p++) { + for (size_t p = 0; p < geom->get_num_primitives(); ++p) { CPT(GeomPrimitive) primitive = geom->get_primitive(p)->decompose(); // Get a new GeomPrimitive of the corresponding type. diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index 9b2db10f2d..daa035dc75 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 */ - int x2, dx2dy2; + UNUSED int x2, dx2dy2; #ifdef INTERP_Z int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index b8baba23c2..49c4550b4a 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -32,7 +32,7 @@ FNAME(flat_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { UNUSED int color; - int or0, og0, ob0, oa0; + UNUSED int or0, og0, ob0, oa0; #define INTERP_Z @@ -160,7 +160,7 @@ FNAME(flat_textured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { ZTextureDef *texture_def; - int or0, og0, ob0, oa0; + UNUSED int or0, og0, ob0, oa0; #define INTERP_Z #define INTERP_ST @@ -399,7 +399,7 @@ FNAME(flat_perspective) (ZBuffer *zb, { ZTextureDef *texture_def; PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx; - int or0, og0, ob0, oa0; + UNUSED int or0, og0, ob0, oa0; #define INTERP_Z #define INTERP_STZ @@ -456,7 +456,7 @@ FNAME(flat_perspective) (ZBuffer *zb, PIXEL *pp; \ int s,t,z,zz; \ int n,dsdx,dtdx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ @@ -596,7 +596,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, PIXEL *pp; \ int s,t,z,zz; \ int n,dsdx,dtdx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ @@ -727,7 +727,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, PIXEL *pp; \ int s,t,sa,ta,z,zz; \ int n,dsdx,dtdx,dsadx,dtadx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,sza,tza,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ @@ -888,7 +888,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, PIXEL *pp; \ int s,t,sa,ta,sb,tb,z,zz; \ int n,dsdx,dtdx,dsadx,dtadx,dsbdx,dtbdx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,sza,tza,szb,tzb,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \