From 5e26aae1ffddef991d59fcb960dfdcfb881ee75f Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Feb 2023 16:40:56 +0100 Subject: [PATCH] cleanup: Fix assorted issues uncovered by clang-tidy --- direct/src/dcparser/dcClassParameter.h | 2 +- dtool/src/dtoolutil/executionEnvironment.cxx | 7 +-- dtool/src/dtoolutil/filename.cxx | 5 +- dtool/src/dtoolutil/lineStreamBuf.h | 2 +- dtool/src/dtoolutil/pfstreamBuf.h | 2 +- dtool/src/interrogate/functionRemap.cxx | 2 +- .../interfaceMakerPythonNative.cxx | 10 +--- dtool/src/prc/configPageManager.cxx | 4 +- dtool/src/prc/pnotify.h | 30 ++++++++++++ panda/src/audio/audioSound.cxx | 2 +- panda/src/audiotraits/openalAudioManager.h | 2 +- panda/src/audiotraits/openalAudioSound.cxx | 2 +- panda/src/audiotraits/openalAudioSound.h | 2 +- panda/src/char/characterJoint.h | 2 +- panda/src/collide/collisionBox.cxx | 2 +- panda/src/collide/collisionHandlerFloor.cxx | 2 +- panda/src/device/evdevInputDevice.cxx | 2 +- panda/src/display/screenshotRequest.cxx | 4 +- panda/src/display/stereoDisplayRegion.h | 2 +- panda/src/downloadertools/multify.cxx | 6 ++- panda/src/egg/eggGroup.cxx | 2 +- panda/src/egldisplay/eglGraphicsPipe.cxx | 20 ++++---- panda/src/event/asyncTask.cxx | 4 +- panda/src/event/asyncTaskManager.h | 2 +- panda/src/express/patchfile.cxx | 2 +- panda/src/gobj/adaptiveLru.cxx | 1 - panda/src/gobj/geom.cxx | 14 +----- panda/src/gobj/texture.cxx | 16 +++---- panda/src/grutil/meshDrawer2D.cxx | 11 ++--- panda/src/mathutil/boundingHexahedron.h | 2 +- panda/src/mathutil/boundingSphere.cxx | 4 +- panda/src/ode/odeJoint.cxx | 8 ++-- panda/src/ode/odeTriMeshData.cxx | 6 +-- panda/src/ode/odeWorld.cxx | 4 +- panda/src/parametrics/nurbsCurve.h | 2 +- panda/src/parametrics/piecewiseCurve.cxx | 12 +++-- panda/src/parametrics/piecewiseCurve.h | 2 +- .../src/particlesystem/lineParticleRenderer.h | 4 +- .../particlesystem/pointParticleRenderer.h | 4 +- .../particlesystem/sparkleParticleRenderer.h | 4 +- .../particlesystem/spriteParticleRenderer.h | 2 +- panda/src/pgraph/antialiasAttrib.cxx | 2 +- panda/src/pgraph/bamFile.cxx | 2 +- panda/src/pgraph/geomTransformer.cxx | 4 ++ panda/src/pgraph/portalClipper.cxx | 1 + panda/src/pgraph/renderState.cxx | 3 -- panda/src/pgraph/sceneGraphReducer.cxx | 2 +- panda/src/pgui/pgEntry.h | 2 +- panda/src/pgui/pgSliderBar.h | 2 +- panda/src/pipeline/cycleDataLockedReader.h | 1 - panda/src/pipeline/cycleDataReader.h | 1 - panda/src/pipeline/pipeline.cxx | 2 +- panda/src/pnmimage/pnmImage.cxx | 20 ++++---- panda/src/pnmimage/pnmimage_base.cxx | 5 +- panda/src/pnmimage/pnmimage_base.h | 2 +- .../pnmimagetypes/pnmFileTypeSGIReader.cxx | 4 +- panda/src/text/dynamicTextPage.cxx | 4 +- panda/src/text/textAssembler.cxx | 1 + panda/src/x11display/x11GraphicsPipe.cxx | 2 +- pandatool/src/eggprogs/eggTextureCards.cxx | 5 +- pandatool/src/gtk-stats/gtkStatsChartMenu.h | 2 +- pandatool/src/gtk-stats/gtkStatsFlameGraph.h | 2 +- pandatool/src/gtk-stats/gtkStatsLabel.h | 1 + pandatool/src/gtk-stats/gtkStatsMonitor.cxx | 2 +- pandatool/src/gtk-stats/gtkStatsMonitor.h | 2 +- pandatool/src/gtk-stats/gtkStatsPianoRoll.h | 2 +- pandatool/src/gtk-stats/gtkStatsStripChart.h | 2 +- pandatool/src/gtk-stats/gtkStatsTimeline.h | 2 +- pandatool/src/palettizer/paletteImage.cxx | 4 +- pandatool/src/progbase/wordWrapStreamBuf.h | 2 +- pandatool/src/xfile/xFile.h | 2 +- pandatool/src/xfile/xFileDataDef.h | 2 +- pandatool/src/xfile/xFileTemplate.h | 2 +- pandatool/src/xfile/xParser.cxx.prebuilt | 46 +++++++++---------- 74 files changed, 183 insertions(+), 173 deletions(-) diff --git a/direct/src/dcparser/dcClassParameter.h b/direct/src/dcparser/dcClassParameter.h index 05b84e84c3..1ec4b856a2 100644 --- a/direct/src/dcparser/dcClassParameter.h +++ b/direct/src/dcparser/dcClassParameter.h @@ -37,7 +37,7 @@ PUBLISHED: const DCClass *get_class() const; public: - virtual DCPackerInterface *get_nested_field(int n) const; + virtual DCPackerInterface *get_nested_field(int n) const final; virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, const std::string &name, const std::string &postname) const; diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index fd46c5e288..34c32d64d3 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -439,12 +439,7 @@ ns_set_environment_variable(const string &var, const string &value) { #ifdef _MSC_VER _putenv_s(var.c_str(), value.c_str()); #else - string putstr = var + "=" + value; - - // putenv() requires us to malloc a new C-style string. - char *put = (char *)malloc(putstr.length() + 1); - strcpy(put, putstr.c_str()); - putenv(put); + setenv(var.c_str(), value.c_str(), 1); #endif } diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 8d319e9b23..abb21a8ee2 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -24,10 +24,13 @@ #ifdef PHAVE_UTIME_H #include +#endif // We assume we have these too. +#ifndef _WIN32 #include #include +#include #endif #ifdef PHAVE_GLOB_H @@ -2317,7 +2320,7 @@ touch() const { // time. For these systems, we'll just temporarily open the file in append // mode, then close it again (it gets closed when the pfstream goes out of // scope). - pfstream file; + pofstream file; return open_append(file); #endif // _WIN32, PHAVE_UTIME_H } diff --git a/dtool/src/dtoolutil/lineStreamBuf.h b/dtool/src/dtoolutil/lineStreamBuf.h index 967d3f1636..cbac956144 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.h +++ b/dtool/src/dtoolutil/lineStreamBuf.h @@ -23,7 +23,7 @@ * whose contents can be continuously extracted as a sequence of lines of * text. */ -class EXPCL_DTOOL_DTOOLUTIL LineStreamBuf : public std::streambuf { +class EXPCL_DTOOL_DTOOLUTIL LineStreamBuf final : public std::streambuf { public: LineStreamBuf(); virtual ~LineStreamBuf(); diff --git a/dtool/src/dtoolutil/pfstreamBuf.h b/dtool/src/dtoolutil/pfstreamBuf.h index c72dff12ae..728c083252 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.h +++ b/dtool/src/dtoolutil/pfstreamBuf.h @@ -41,7 +41,7 @@ #endif // WIN_PIPE_CALLS -class EXPCL_DTOOL_DTOOLUTIL PipeStreamBuf : public std::streambuf { +class EXPCL_DTOOL_DTOOLUTIL PipeStreamBuf final : public std::streambuf { public: enum Direction { Input, Output }; diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 52ff496dac..725b1f578b 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -495,7 +495,7 @@ get_call_str(const string &container, const vector_string &pexprs) const { separator = ", "; } - size_t pn = _first_true_parameter; + size_t pn; size_t num_parameters = pexprs.size(); for (pn = _first_true_parameter; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index ad3bd9d2fc..d3dc0302a9 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1664,11 +1664,6 @@ write_module_class(ostream &out, Object *obj) { std::string cClassName = obj->_itype.get_true_name(); std::string export_class_name = classNameFromCppName(obj->_itype.get_name(), false); - bool is_runtime_typed = IsPandaTypedObject(obj->_itype._cpptype->as_struct_type()); - if (!is_runtime_typed && has_get_class_type_function(obj->_itype._cpptype)) { - is_runtime_typed = true; - } - out << "/**\n"; out << " * Python method tables for " << ClassName << " (" << export_class_name << ")\n" ; out << " */\n"; @@ -5109,9 +5104,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, } CPPEnumType *enum_type = (CPPEnumType *)TypeManager::unwrap(type); - CPPType *underlying_type = enum_type->get_underlying_type(); - underlying_type = TypeManager::unwrap_const(underlying_type); - + //CPPType *underlying_type = enum_type->get_underlying_type(); + //underlying_type = TypeManager::unwrap_const(underlying_type); //indent(out, indent_level); //underlying_type->output_instance(out, param_name + "_val", &parser); //out << default_expr << ";\n"; diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index edf40a9555..78a8484854 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -122,13 +122,13 @@ reload_implicit_pages() { const char *log_filename; }; #ifdef _WIN32 - const BlobInfo *blobinfo = (const BlobInfo *)GetProcAddress(GetModuleHandle(NULL), "blobinfo"); + const BlobInfo *blobinfo = (const BlobInfo *)GetProcAddress(GetModuleHandle(nullptr), "blobinfo"); #elif defined(RTLD_MAIN_ONLY) const BlobInfo *blobinfo = (const BlobInfo *)dlsym(RTLD_MAIN_ONLY, "blobinfo"); //#elif defined(RTLD_SELF) // const BlobInfo *blobinfo = (const BlobInfo *)dlsym(RTLD_SELF, "blobinfo"); #else - const BlobInfo *blobinfo = (const BlobInfo *)dlsym(dlopen(NULL, RTLD_NOW), "blobinfo"); + const BlobInfo *blobinfo = (const BlobInfo *)dlsym(dlopen(nullptr, RTLD_NOW), "blobinfo"); #endif if (blobinfo == nullptr) { #ifndef _WIN32 diff --git a/dtool/src/prc/pnotify.h b/dtool/src/prc/pnotify.h index 5b2ccd482c..c88f8a8b33 100644 --- a/dtool/src/prc/pnotify.h +++ b/dtool/src/prc/pnotify.h @@ -156,6 +156,36 @@ private: #define nassert_raise(message) Notify::write_string(message) +#elif defined(__clang_analyzer__) + +// We define these so that clang-tidy can generally assume that assertions will +// not occur, since we don't really care about things like minor memory leaks +// on assertion failure. + +#define nassertr(condition, return_value) \ + { \ + if (!(condition)) { \ + abort(); \ + return return_value; \ + } \ + } + +#define nassertv(condition) \ + { \ + if (!(condition)) { \ + abort(); \ + return; \ + } \ + } + +#define nassertd(condition) \ + if (!(condition)) + +#define nassertr_always(condition, return_value) nassertr(condition, return_value) +#define nassertv_always(condition) nassertv(condition) + +#define nassert_raise(message) abort() + #else // NDEBUG #define nassertr(condition, return_value) \ diff --git a/panda/src/audio/audioSound.cxx b/panda/src/audio/audioSound.cxx index 6285b1bbf9..946d1bd9f0 100644 --- a/panda/src/audio/audioSound.cxx +++ b/panda/src/audio/audioSound.cxx @@ -52,7 +52,7 @@ set_3d_direction(LVector3 d) { LVector3 AudioSound:: get_3d_direction() const { // Intentionally blank. - return ( 0.0f, 0.0f, 0.0f ); + return { 0.0f, 0.0f, 0.0f }; } void AudioSound:: diff --git a/panda/src/audiotraits/openalAudioManager.h b/panda/src/audiotraits/openalAudioManager.h index a0e3d549bb..3970c50627 100644 --- a/panda/src/audiotraits/openalAudioManager.h +++ b/panda/src/audiotraits/openalAudioManager.h @@ -36,7 +36,7 @@ class OpenALAudioSound; extern void al_audio_errcheck(const char *context); extern void alc_audio_errcheck(const char *context,ALCdevice* device); -class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { +class EXPCL_OPENAL_AUDIO OpenALAudioManager final : public AudioManager { class SoundData; friend class OpenALAudioSound; diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 13b7ff1305..43036c73b0 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -497,7 +497,7 @@ correct_calibrated_clock(double rtc, double t) { } set_calibrated_clock(rtc, cc, scale); } - cc = (rtc - _calibrated_clock_base) * _calibrated_clock_scale; + //cc = (rtc - _calibrated_clock_base) * _calibrated_clock_scale; } /** diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index a3d19dca08..cc643ac20c 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -29,7 +29,7 @@ #include #endif -class EXPCL_OPENAL_AUDIO OpenALAudioSound : public AudioSound { +class EXPCL_OPENAL_AUDIO OpenALAudioSound final : public AudioSound { friend class OpenALAudioManager; public: diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index 83d155f184..aaeb6690ed 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -46,7 +46,7 @@ public: virtual bool update_internals(PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, - Thread *current_thread); + Thread *current_thread) final; virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat); PUBLISHED: diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index ab5cb21717..5b6dff09e0 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -1251,7 +1251,7 @@ dist_to_polygon(const LPoint2 &p, const PointDef *points, size_t num_points) con if (d >= 0.0f) { if (!got_dist || d < best_dist) { best_dist = d; - got_dist = true; + //got_dist = true; } } diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index 8c9838eea7..cae2e6bf06 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -111,7 +111,7 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod if (!got_max && got_min) { // We've fallen through the world, but we're also under some walkable // geometry. Move us up to the lowest surface: - got_max = true; + //got_max = true; max_height = min_height; highest = lowest; } diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index f43fc3c03d..8fb35ed477 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -169,7 +169,7 @@ EvdevInputDevice:: if (_fd != -1) { if (_ff_id != -1) { // Remove force-feedback effect. - do_set_vibration(0, 0); + EvdevInputDevice::do_set_vibration(0, 0); ioctl(_fd, EVIOCRMFF, _ff_id); _ff_id = -1; } diff --git a/panda/src/display/screenshotRequest.cxx b/panda/src/display/screenshotRequest.cxx index bb05b448c6..8e9c8d33f1 100644 --- a/panda/src/display/screenshotRequest.cxx +++ b/panda/src/display/screenshotRequest.cxx @@ -28,7 +28,7 @@ set_view_data(int view, const void *ptr) { Texture *tex = get_result(); PTA_uchar new_image = tex->modify_ram_image(); unsigned char *image_ptr = new_image.p(); - size_t image_size = tex->get_ram_image_size(); + size_t image_size; if (z >= 0 || view > 0) { image_size = tex->get_expected_ram_page_size(); if (z >= 0) { @@ -43,6 +43,8 @@ set_view_data(int view, const void *ptr) { return; } } + } else { + image_size = tex->get_ram_image_size(); } memcpy(image_ptr, ptr, image_size); } diff --git a/panda/src/display/stereoDisplayRegion.h b/panda/src/display/stereoDisplayRegion.h index 940d793f4b..ecd1b6d009 100644 --- a/panda/src/display/stereoDisplayRegion.h +++ b/panda/src/display/stereoDisplayRegion.h @@ -29,7 +29,7 @@ * eyes together. To access the left or right eyes independently, use * get_left_eye() and get_right_eye(). */ -class EXPCL_PANDA_DISPLAY StereoDisplayRegion : public DisplayRegion { +class EXPCL_PANDA_DISPLAY StereoDisplayRegion final : public DisplayRegion { protected: StereoDisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions, diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index da3789d3cb..6d0bdd12f6 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -785,9 +785,11 @@ main(int argc, char **argv) { // argument if there is not one already. if (argc >= 2) { if (*argv[1] != '-' && *argv[1] != '\0') { - char *new_arg = (char *)PANDA_MALLOC_ARRAY(strlen(argv[1]) + 2); + size_t len = strlen(argv[1]); + char *new_arg = (char *)PANDA_MALLOC_ARRAY(len + 2); new_arg[0] = '-'; - strcpy(new_arg + 1, argv[1]); + memcpy(new_arg + 1, argv[1], len); + new_arg[len + 1] = 0; argv[1] = new_arg; } } diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index cce47550f2..f47e0cab98 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -1403,7 +1403,7 @@ ostream &operator << (ostream &out, EggGroup::CollideFlags t) { } if (bits & EggGroup::CF_level) { out << space << "level"; - space = " "; + //space = " "; } return out; } diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx index 6d4a58adc5..c32ea29351 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.cxx +++ b/panda/src/egldisplay/eglGraphicsPipe.cxx @@ -241,8 +241,8 @@ make_output(const std::string &name, return nullptr; } - eglGraphicsStateGuardian *eglgsg = 0; - if (gsg != 0) { + eglGraphicsStateGuardian *eglgsg = nullptr; + if (gsg != nullptr) { DCAST_INTO_R(eglgsg, gsg, nullptr); } @@ -282,7 +282,7 @@ make_output(const std::string &name, // Second thing to try: a GL(ES(2))GraphicsBuffer if (retry == 1) { - if ((host==0)|| + if (host == nullptr || // (!gl_support_fbo)|| ((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { @@ -290,7 +290,7 @@ make_output(const std::string &name, } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. - if ((flags & BF_fb_props_optional)==0) { + if ((flags & BF_fb_props_optional) == 0) { if (fb_prop.get_indexed_color() > 0 || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { @@ -299,12 +299,12 @@ make_output(const std::string &name, } // Early success - if we are sure that this buffer WILL meet specs, we can // precertify it. - if ((eglgsg != 0) && - (eglgsg->is_valid()) && - (!eglgsg->needs_reset()) && - (eglgsg->_supports_framebuffer_object) && - (eglgsg->_glDrawBuffers != 0)&& - (fb_prop.is_basic())) { + if (eglgsg != nullptr && + eglgsg->is_valid() && + !eglgsg->needs_reset() && + eglgsg->_supports_framebuffer_object && + eglgsg->_glDrawBuffers != nullptr && + fb_prop.is_basic()) { precertify = true; } #ifdef OPENGLES_2 diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index 0ec0c6d8b7..85670e4cf4 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -209,7 +209,7 @@ set_name(const string &name) { --p; trimmed = p; } else { - p = trimmed; + //p = trimmed; break; } } @@ -237,7 +237,7 @@ get_name_prefix() const { --p; trimmed = p; } else { - p = trimmed; + //p = trimmed; break; } } diff --git a/panda/src/event/asyncTaskManager.h b/panda/src/event/asyncTaskManager.h index 2825895078..62a2590aa5 100644 --- a/panda/src/event/asyncTaskManager.h +++ b/panda/src/event/asyncTaskManager.h @@ -112,7 +112,7 @@ protected: bool do_has_task(AsyncTask *task) const; - virtual void do_output(std::ostream &out) const; + void do_output(std::ostream &out) const; private: static void make_global_ptr(); diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 2c784fb4d2..748c9a76ba 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -1074,7 +1074,7 @@ compute_file_patches(ostream &write_stream, uint32_t remaining_bytes = result_file_length - start_pos; cache_add_and_copy(write_stream, remaining_bytes, &buffer_new[start_pos], 0, 0); - start_pos += remaining_bytes; + //start_pos += remaining_bytes; } PANDA_FREE_ARRAY(link_table); diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index 54ed81a3c8..20132cc7a4 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -128,7 +128,6 @@ update_page(AdaptiveLruPage *page) { page->_average_frame_utilization *= 1.0f - _weight; } - target_priority = page->_priority; if (page->_average_frame_utilization >= 1.0f) { int integer_average_frame_utilization; diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 624216d38c..8a9ae9c35e 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -1350,8 +1350,6 @@ get_next_modified() { */ void Geom:: compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { - int num_vertices = 0; - // Get the vertex data, after animation. CPT(GeomVertexData) vertex_data = get_animated_vertex_data(true, current_thread); @@ -1451,16 +1449,8 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { case BoundingVolume::BT_box: cdata->_internal_bounds = new BoundingBox(pmin, pmax); } - - Primitives::const_iterator pi; - for (pi = cdata->_primitives.begin(); - pi != cdata->_primitives.end(); - ++pi) { - CPT(GeomPrimitive) prim = (*pi).get_read_pointer(current_thread); - num_vertices += prim->get_num_vertices(); - } - - } else { + } + else { // No points; empty bounding volume. if (btype == BoundingVolume::BT_sphere) { cdata->_internal_bounds = new BoundingSphere; diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index d84cd4ca93..5103515aac 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -6105,14 +6105,6 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, } } - // Choose an appropriate quality level. - if (quality_level == Texture::QL_default) { - quality_level = cdata->_quality_level; - } - if (quality_level == Texture::QL_default) { - quality_level = texture_quality_level; - } - if (compression == CM_rgtc) { // We should compress RGTC ourselves, as squish does not support it. if (cdata->_component_type != T_unsigned_byte) { @@ -6185,6 +6177,14 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, } #ifdef HAVE_SQUISH + // Choose an appropriate quality level. + if (quality_level == Texture::QL_default) { + quality_level = cdata->_quality_level; + } + if (quality_level == Texture::QL_default) { + quality_level = texture_quality_level; + } + if (cdata->_texture_type != TT_3d_texture && cdata->_texture_type != TT_2d_texture_array && cdata->_component_type == T_unsigned_byte) { diff --git a/panda/src/grutil/meshDrawer2D.cxx b/panda/src/grutil/meshDrawer2D.cxx index 235b5478ea..cb33ec2e3c 100644 --- a/panda/src/grutil/meshDrawer2D.cxx +++ b/panda/src/grutil/meshDrawer2D.cxx @@ -126,8 +126,6 @@ void MeshDrawer2D::end() { } - - /** * Draws a tiled rectangle, size of tiles is in us and vs */ @@ -138,7 +136,7 @@ rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, ) { PN_stdfloat x_fit = w/us; - PN_stdfloat y_fit = h/vs; + PN_stdfloat y_fit; PN_stdfloat x_pos = x; while (x_fit > 0){ @@ -149,7 +147,7 @@ rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, PN_stdfloat fixed_us = us; PN_stdfloat fixed_vs = vs; - // we are cuttin in the middle of a tile x direction + // we are cutting in the middle of a tile x direction if (x_fit < 1){ fixed_us = w; while (fixed_us > us){ @@ -157,7 +155,7 @@ rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, } } - // we are cuttin in the middel of a tile y directon + // we are cutting in the middle of a tile y directon if (y_fit < 1){ fixed_vs = h; while (fixed_vs > vs){ @@ -173,11 +171,8 @@ rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, x_pos += us; x_fit -= 1; } - - } - /** * Draws a 2d rectangle, with borders and corders, taken from the surrounding * texture diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index de09e03dac..8b899001d2 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -49,7 +49,7 @@ public: virtual LPoint3 get_max() const; virtual LPoint3 get_approx_center() const; - virtual void xform(const LMatrix4 &mat); + virtual void xform(const LMatrix4 &mat) final; virtual void output(std::ostream &out) const; virtual void write(std::ostream &out, int indent_level = 0) const; diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index beb6cb6309..6e30ff41ab 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -501,9 +501,9 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { if (IS_NEARLY_ZERO(radical)) { // Tangent. - t1 = t2 = -B / (2.0f*A); + t1 = -B / (2.0f*A); return (t1 >= 0.0f && t1 <= 1.0f) ? - IF_possible | IF_some : IF_no_intersection; + IF_possible | IF_some : IF_no_intersection; } if (radical < 0.0f) { diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index 4ada7fefa5..eaf86b313e 100644 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -32,8 +32,8 @@ OdeJoint:: OdeJoint() : _id(nullptr) { if (odejoint_cat.is_debug()) { - std::ostream &out = odejoint_cat.debug(); - out << get_type() << "(" << _id << ")\n"; + odejoint_cat.debug() + << "OdeJoint(" << _id << ")\n"; } } @@ -41,8 +41,8 @@ OdeJoint:: OdeJoint(dJointID id) : _id(id) { if (odejoint_cat.is_debug()) { - std::ostream &out = odejoint_cat.debug(); - out << get_type() << "(" << _id << ")\n"; + odejoint_cat.debug() + << "OdeJoint(" << _id << ")\n"; } } diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 8e741529f6..65e774953c 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -102,7 +102,7 @@ OdeTriMeshData(const NodePath& model, bool use_normals) : _num_vertices(0), _num_faces(0) { if (odetrimeshdata_cat.is_debug()) { - odetrimeshdata_cat.debug() << get_type() << "(" << _id << ")" << "\n"; + odetrimeshdata_cat.debug() << "OdeTriMeshData(" << _id << ")" << "\n"; } process_model(model, use_normals); @@ -142,7 +142,7 @@ OdeTriMeshData(const OdeTriMeshData &other) { OdeTriMeshData:: ~OdeTriMeshData() { if (odetrimeshdata_cat.is_debug()) { - odetrimeshdata_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n"; + odetrimeshdata_cat.debug() << "~OdeTriMeshData(" << _id << ")" << "\n"; } destroy(); if (_vertices != nullptr) { @@ -165,7 +165,7 @@ OdeTriMeshData:: void OdeTriMeshData:: destroy() { if (odetrimeshdata_cat.is_debug()) { - odetrimeshdata_cat.debug() << get_type() << "::destroy(" << _id << ")" << "\n"; + odetrimeshdata_cat.debug() << "OdeTriMeshData::destroy(" << _id << ")" << "\n"; } if (_id != nullptr) { dGeomTriMeshDataDestroy(_id); diff --git a/panda/src/ode/odeWorld.cxx b/panda/src/ode/odeWorld.cxx index 66a7233dca..b3865e4faa 100644 --- a/panda/src/ode/odeWorld.cxx +++ b/panda/src/ode/odeWorld.cxx @@ -21,7 +21,7 @@ OdeWorld:: OdeWorld() : _id(dWorldCreate()) { if (odeworld_cat.is_debug()) { - odeworld_cat.debug() << get_type() << "(" << _id << ")" << "\n"; + odeworld_cat.debug() << "OdeWorld(" << _id << ")" << "\n"; } _num_surfaces = 0; @@ -37,7 +37,7 @@ OdeWorld(const OdeWorld ©) : OdeWorld:: ~OdeWorld() { if (odeworld_cat.is_debug()) { - odeworld_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n"; + odeworld_cat.debug() << "~OdeWorld(" << _id << ")" << "\n"; } } diff --git a/panda/src/parametrics/nurbsCurve.h b/panda/src/parametrics/nurbsCurve.h index 990d5dee59..06f3177d72 100644 --- a/panda/src/parametrics/nurbsCurve.h +++ b/panda/src/parametrics/nurbsCurve.h @@ -38,7 +38,7 @@ * "NurbsCurve" instead of this one, and performs most of the NURBS curve * functions. This class then becomes vestigial. */ -class EXPCL_PANDA_PARAMETRICS NurbsCurve : public PiecewiseCurve, public NurbsCurveInterface { +class EXPCL_PANDA_PARAMETRICS NurbsCurve final : public PiecewiseCurve, public NurbsCurveInterface { PUBLISHED: NurbsCurve(); NurbsCurve(const ParametricCurve &pc); diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index f5e2fadad9..8475dd5869 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -85,7 +85,9 @@ bool PiecewiseCurve:: get_tangent(PN_stdfloat t, LVecBase3 &tangent) const { const ParametricCurve *curve; bool result = find_curve(curve, t); - + if (curve == nullptr){ + return false; + } // We use | instead of || so we won't short-circuit this calculation. return result | curve->get_tangent(t, tangent); } @@ -98,7 +100,9 @@ bool PiecewiseCurve:: get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { const ParametricCurve *curve; bool result = find_curve(curve, t); - + if (curve == nullptr){ + return false; + } // We use | instead of || so we won't short-circuit this calculation. return result | curve->get_2ndtangent(t, tangent2); } @@ -185,7 +189,9 @@ bool PiecewiseCurve:: get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { const ParametricCurve *curve; bool result = find_curve(curve, t); - + if (curve == nullptr){ + return false; + } // We use | instead of || so we won't short-circuit this calculation. return result | curve->get_pt(t, point, tangent); } diff --git a/panda/src/parametrics/piecewiseCurve.h b/panda/src/parametrics/piecewiseCurve.h index df979a5031..2227112541 100644 --- a/panda/src/parametrics/piecewiseCurve.h +++ b/panda/src/parametrics/piecewiseCurve.h @@ -81,7 +81,7 @@ protected: Curveseg(ParametricCurve *c, PN_stdfloat t) : _curve(c), _tend(t) {} PT(ParametricCurve) _curve; - PN_stdfloat _tend; + PN_stdfloat _tend = 0.0f; }; pvector _segs; diff --git a/panda/src/particlesystem/lineParticleRenderer.h b/panda/src/particlesystem/lineParticleRenderer.h index ecec62fc8e..f314ee1cbe 100644 --- a/panda/src/particlesystem/lineParticleRenderer.h +++ b/panda/src/particlesystem/lineParticleRenderer.h @@ -71,10 +71,10 @@ private: virtual void birth_particle(int index); virtual void kill_particle(int index); - virtual void init_geoms(); + virtual void init_geoms() final; virtual void render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles); - virtual void resize_pool(int new_size); + virtual void resize_pool(int new_size) final; static PStatCollector _render_collector; }; diff --git a/panda/src/particlesystem/pointParticleRenderer.h b/panda/src/particlesystem/pointParticleRenderer.h index ff2f7b3f98..6620d0c4c4 100644 --- a/panda/src/particlesystem/pointParticleRenderer.h +++ b/panda/src/particlesystem/pointParticleRenderer.h @@ -89,10 +89,10 @@ private: virtual void birth_particle(int index); virtual void kill_particle(int index); - virtual void init_geoms(); + virtual void init_geoms() final; virtual void render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles); - virtual void resize_pool(int new_size); + virtual void resize_pool(int new_size) final; static PStatCollector _render_collector; }; diff --git a/panda/src/particlesystem/sparkleParticleRenderer.h b/panda/src/particlesystem/sparkleParticleRenderer.h index 6b81e07cc5..dc6ed4b95a 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.h +++ b/panda/src/particlesystem/sparkleParticleRenderer.h @@ -89,10 +89,10 @@ private: virtual void birth_particle(int index); virtual void kill_particle(int index); - virtual void init_geoms(); + virtual void init_geoms() final; virtual void render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles); - virtual void resize_pool(int new_size); + virtual void resize_pool(int new_size) final; static PStatCollector _render_collector; }; diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index 0de03533d6..f23533118c 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -259,7 +259,7 @@ private: virtual void birth_particle(int index); virtual void kill_particle(int index); - virtual void init_geoms(); + virtual void init_geoms() final; virtual void render(pvector< PT(PhysicsObject) > &po_vector, int ttl_particles); virtual void resize_pool(int new_size); diff --git a/panda/src/pgraph/antialiasAttrib.cxx b/panda/src/pgraph/antialiasAttrib.cxx index 260b4fdef1..65f7577792 100644 --- a/panda/src/pgraph/antialiasAttrib.cxx +++ b/panda/src/pgraph/antialiasAttrib.cxx @@ -106,7 +106,7 @@ output(std::ostream &out) const { } if ((_mode & M_better) != 0) { out << sep << "better"; - sep = '|'; + //sep = '|'; } } diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index 5bf0d5af88..e4a729ca53 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -145,7 +145,7 @@ read_node(bool report_errors) { object = read_object(); } - if (object == TypedWritable::Null) { + if (object == nullptr) { if (report_errors) { loader_cat.error() << "Bam file " << _bam_filename << " is empty.\n"; } diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index 17deed90f2..83a1ffd290 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -1460,6 +1460,10 @@ remove_unused_vertices(const GeomVertexData *vdata) { } int num_vertices = vdata->get_num_rows(); + if (num_vertices <= 0) { + return; + } + int new_num_vertices = referenced_vertices.get_num_on_bits(); if (num_vertices <= new_num_vertices) { // All vertices are used. diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index d980ac9d41..cd186e8e13 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -208,6 +208,7 @@ prepare_portal(const NodePath &node_path) if (node->is_of_type(PortalNode::get_class_type())) { _portal_node = DCAST(PortalNode, node); } + nassertr(_portal_node != nullptr, false); // Get the geometry from the portal if (portal_cat.is_spam()) { diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 76884ea0bb..da9d1bca97 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -1897,8 +1897,6 @@ int RenderState:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); - int num_attribs = 0; - RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); for (size_t i = 0; i < (*_read_overrides).size(); ++i) { int override = (*_read_overrides)[i]; @@ -1909,7 +1907,6 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { if (slot > 0 && slot < reg->get_max_slots()) { _attributes[slot].set(attrib, override); _filled_slots.set_bit(slot); - ++num_attribs; } } } diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index 06a80e5a4d..1276cb3bb5 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -346,7 +346,7 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, new_node->copy_children(child_node); node->replace_child(child_node, new_node); - child_node = new_node; + //child_node = new_node; } } } diff --git a/panda/src/pgui/pgEntry.h b/panda/src/pgui/pgEntry.h index a12c4cc70b..1ef27e60a3 100644 --- a/panda/src/pgui/pgEntry.h +++ b/panda/src/pgui/pgEntry.h @@ -115,7 +115,7 @@ PUBLISHED: void set_text_def(int state, TextNode *node); TextNode *get_text_def(int state) const; - virtual void set_active(bool active); + virtual void set_active(bool active) final; virtual void set_focus(bool focus); INLINE static std::string get_accept_prefix(); diff --git a/panda/src/pgui/pgSliderBar.h b/panda/src/pgui/pgSliderBar.h index 4049f9aa74..3b387d9cc8 100644 --- a/panda/src/pgui/pgSliderBar.h +++ b/panda/src/pgui/pgSliderBar.h @@ -96,7 +96,7 @@ PUBLISHED: INLINE static std::string get_adjust_prefix(); INLINE std::string get_adjust_event() const; - virtual void set_active(bool active); + virtual void set_active(bool active) final; void remanage(); void recompute(); diff --git a/panda/src/pipeline/cycleDataLockedReader.h b/panda/src/pipeline/cycleDataLockedReader.h index 62c1a72b1a..56cb04cd26 100644 --- a/panda/src/pipeline/cycleDataLockedReader.h +++ b/panda/src/pipeline/cycleDataLockedReader.h @@ -64,7 +64,6 @@ private: const PipelineCycler *_cycler; Thread *_current_thread; const CycleDataType *_pointer; - CycleDataType *_write_pointer; #else // !DO_PIPELINING // This is all we need for the trivial, do-nothing implementation. const CycleDataType *_pointer; diff --git a/panda/src/pipeline/cycleDataReader.h b/panda/src/pipeline/cycleDataReader.h index 58ba9e77ac..9e23a4699b 100644 --- a/panda/src/pipeline/cycleDataReader.h +++ b/panda/src/pipeline/cycleDataReader.h @@ -56,7 +56,6 @@ private: const PipelineCycler *_cycler; Thread *_current_thread; const CycleDataType *_pointer; - CycleDataType *_write_pointer; #else // !DO_PIPELINING // This is all we need for the trivial, do-nothing implementation. const CycleDataType *_pointer; diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 90de20246c..e892a88ee7 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -195,7 +195,7 @@ cycle() { if (cycler->is_dirty()) { // The cycler is still dirty. Add it back to the dirty list. - nassertd(!cycler->is_dirty(prev_seq)); + nassertd(!cycler->is_dirty(prev_seq)) break; cycler->insert_before(&_dirty); cycler->mark_dirty(next_seq); ++_num_dirty_cyclers; diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 7f4c32c558..9c6ca23abb 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -1991,13 +1991,11 @@ quantize(size_t max_colors) { void PNMImage:: perlin_noise_fill(float sx, float sy, int table_size, unsigned long seed, float ox, float oy) { - float x, y; - float noise; PerlinNoise2 perlin (sx * _x_size, sy * _y_size, table_size, seed); - for (x = 0; x < _x_size; ++x) { - for (y = 0; y < _y_size; ++y) { - noise = perlin.noise(x + ox, y + oy); - set_xel(x, y, 0.5 * (noise + 1.0)); + for (int x = 0; x < _x_size; ++x) { + for (int y = 0; y < _y_size; ++y) { + float noise = perlin.noise(x + ox, y + oy); + set_xel(x, y, 0.5f * (noise + 1.0f)); } } } @@ -2008,12 +2006,10 @@ perlin_noise_fill(float sx, float sy, int table_size, unsigned long seed, */ void PNMImage:: perlin_noise_fill(StackedPerlinNoise2 &perlin) { - float x, y; - float noise; - for (x = 0; x < _x_size; ++x) { - for (y = 0; y < _y_size; ++y) { - noise = perlin.noise(x / (float) _x_size, y / (float) _y_size); - set_xel(x, y, 0.5 * (noise + 1.0)); + for (int x = 0; x < _x_size; ++x) { + for (int y = 0; y < _y_size; ++y) { + float noise = perlin.noise(x / (float) _x_size, y / (float) _y_size); + set_xel(x, y, 0.5f * (noise + 1.0f)); } } } diff --git a/panda/src/pnmimage/pnmimage_base.cxx b/panda/src/pnmimage/pnmimage_base.cxx index d037750088..5b3f1c86c3 100644 --- a/panda/src/pnmimage/pnmimage_base.cxx +++ b/panda/src/pnmimage/pnmimage_base.cxx @@ -52,13 +52,12 @@ pm_error(const char *format, ...) { va_start(ap, format); static const size_t buffer_size = 1024; - char buffer[buffer_size]; + char buffer[buffer_size + 1]; vsnprintf(buffer, buffer_size, format, ap); + buffer[buffer_size] = 0; va_end(ap); - nassertv(strlen(buffer) < buffer_size); - pnmimage_cat.error() << buffer << "\n"; // Now we're supposed to exit. Inconvenient if we were running Panda diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index 5e45d9d57b..e68e766b88 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -113,7 +113,7 @@ typedef gray xelval; // pnm defines these functions, and it's easier to emulate them than to // rewrite the code that calls them. EXPCL_PANDA_PNMIMAGE void pm_message(const char *format, ...); -EXPCL_PANDA_PNMIMAGE void pm_error(const char *format, ...); // doesn't return. +EXPCL_PANDA_PNMIMAGE void pm_error [[noreturn]] (const char *format, ...); EXPCL_PANDA_PNMIMAGE int pm_maxvaltobits(int maxval); EXPCL_PANDA_PNMIMAGE int pm_bitstomaxval(int bits); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index fafb625fac..03f846b5cd 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -386,10 +386,10 @@ rle_decompress(ScanElem *src, --srcleft; count = (int)(el & 0x7f); - if( count == 0 ) - return; if( destleft < count ) pm_error("RLE error: too much input data (space left %d, need %d)", destleft, count); + if( count == 0 ) + return; destleft -= count; if( el & 0x80 ) { if( srcleft < count ) diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index 7bfe582040..b7b7271854 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -203,8 +203,6 @@ find_hole(int &x, int &y, int x_size, int y_size) const { // Scan along the row at 'y'. x = 0; while (x + x_size <= _size[0]) { - int next_x = x; - // Consider the spot at x, y. DynamicTextGlyph *overlap = find_overlap(x, y, x_size, y_size); @@ -213,7 +211,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { return true; } - next_x = overlap->_x + overlap->_x_size; + int next_x = overlap->_x + overlap->_x_size; next_y = std::min(next_y, overlap->_y + overlap->_y_size); nassertr(next_x > x, false); x = next_x; diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 393c3f74d9..78e3e4adbb 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -538,6 +538,7 @@ assemble_text() { PlacedGlyphs::const_iterator pgi; for (pgi = placed_glyphs.begin(); pgi != placed_glyphs.end(); ++pgi) { const GlyphPlacement &placement = (*pgi); + nassertd(placement._properties != nullptr) continue; if (placement._properties != properties) { // Get a new set of properties for future glyphs. diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index ed5c6a05b5..bfbacfc972 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -437,7 +437,7 @@ send_startup_notification() { // Allocate enough room for the message, with room for escape characters. char *message = (char *)alloca(_startup_id.size() * 2 + 14); - strcpy(message, "remove: ID=\""); + memcpy(message, "remove: ID=\"", 12); char *p = message + 12; for (char c : _startup_id) { diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx index bb3350f02c..255b145a8e 100644 --- a/pandatool/src/eggprogs/eggTextureCards.cxx +++ b/pandatool/src/eggprogs/eggTextureCards.cxx @@ -379,7 +379,8 @@ run() { EggVertex *v1, *v2, *v3, *v4; - if (!_got_pixel_scale) { + bool got_pixel_scale = _got_pixel_scale; + if (!got_pixel_scale) { // If we don't have a per-texture pixel scale, all the polygons will be // the same size, and hence may all share the same four vertices. make_vertices(_polygon_geometry, vpool, v1, v2, v3, v4); @@ -410,7 +411,7 @@ run() { all_ok = false; } - if (_got_pixel_scale) { + if (got_pixel_scale) { if (texture_ok) { make_vertices(geometry, vpool, v1, v2, v3, v4); } else { diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.h b/pandatool/src/gtk-stats/gtkStatsChartMenu.h index 687fe827e5..f2dfb6da7f 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.h +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.h @@ -15,10 +15,10 @@ #define GTKSTATSCHARTMENU_H #include "pandatoolbase.h" +#include "gtkStatsMonitor.h" #include -class GtkStatsMonitor; class PStatView; class PStatViewLevel; diff --git a/pandatool/src/gtk-stats/gtkStatsFlameGraph.h b/pandatool/src/gtk-stats/gtkStatsFlameGraph.h index 7e29ac6bcc..eb2eb5e5e4 100644 --- a/pandatool/src/gtk-stats/gtkStatsFlameGraph.h +++ b/pandatool/src/gtk-stats/gtkStatsFlameGraph.h @@ -25,7 +25,7 @@ class GtkStatsLabel; * A window that draws a flame chart, which shows the collectors explicitly * stopping and starting, one frame at a time. */ -class GtkStatsFlameGraph : public PStatFlameGraph, public GtkStatsGraph { +class GtkStatsFlameGraph final : public PStatFlameGraph, public GtkStatsGraph { public: GtkStatsFlameGraph(GtkStatsMonitor *monitor, int thread_index, int collector_index=-1); diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.h b/pandatool/src/gtk-stats/gtkStatsLabel.h index 6a4768f627..3f07a4e970 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.h +++ b/pandatool/src/gtk-stats/gtkStatsLabel.h @@ -15,6 +15,7 @@ #define GTKSTATSLABEL_H #include "pandatoolbase.h" +#include "luse.h" #include #include diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index d48b9dc531..8373720f90 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -547,7 +547,7 @@ setup_speed_menu() { self->set_scroll_speed(12); } }), this); - group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); + //group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); item = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.h b/pandatool/src/gtk-stats/gtkStatsMonitor.h index 32c8b09b43..6a6c1e091f 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.h +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.h @@ -16,7 +16,6 @@ #include "pandatoolbase.h" -#include "gtkStatsGraph.h" #include "pStatMonitor.h" #include "pointerTo.h" #include "pset.h" @@ -25,6 +24,7 @@ #include +class GtkStatsGraph; class GtkStatsServer; class GtkStatsChartMenu; diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.h b/pandatool/src/gtk-stats/gtkStatsPianoRoll.h index 39261aabfe..e3dd892dcb 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.h +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.h @@ -28,7 +28,7 @@ class GtkStatsMonitor; * A window that draws a piano-roll style chart, which shows the collectors * explicitly stopping and starting, one frame at a time. */ -class GtkStatsPianoRoll : public PStatPianoRoll, public GtkStatsGraph { +class GtkStatsPianoRoll final : public PStatPianoRoll, public GtkStatsGraph { public: GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index); virtual ~GtkStatsPianoRoll(); diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.h b/pandatool/src/gtk-stats/gtkStatsStripChart.h index 760930ef6f..687c3e7049 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.h +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.h @@ -27,7 +27,7 @@ class GtkStatsMonitor; /** * A window that draws a strip chart, given a view. */ -class GtkStatsStripChart : public PStatStripChart, public GtkStatsGraph { +class GtkStatsStripChart final : public PStatStripChart, public GtkStatsGraph { public: GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index, int collector_index, bool show_level); diff --git a/pandatool/src/gtk-stats/gtkStatsTimeline.h b/pandatool/src/gtk-stats/gtkStatsTimeline.h index 9bdd8967f7..37f3f38167 100644 --- a/pandatool/src/gtk-stats/gtkStatsTimeline.h +++ b/pandatool/src/gtk-stats/gtkStatsTimeline.h @@ -26,7 +26,7 @@ class GtkStatsMonitor; * horizontal scrolling timeline, with concurrent start/stop pairs stacked * underneath each other. */ -class GtkStatsTimeline : public PStatTimeline, public GtkStatsGraph { +class GtkStatsTimeline final : public PStatTimeline, public GtkStatsGraph { public: GtkStatsTimeline(GtkStatsMonitor *monitor); virtual ~GtkStatsTimeline(); diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index 871b71ca40..c02e13a2ad 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -789,8 +789,6 @@ find_hole(int &x, int &y, int x_size, int y_size) const { // Scan along the row at 'y'. x = 0; while (x + x_size <= _x_size) { - int next_x = x; - // Consider the spot at x, y. TexturePlacement *overlap = find_overlap(x, y, x_size, y_size); @@ -799,7 +797,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { return true; } - next_x = overlap->get_placed_x() + overlap->get_placed_x_size(); + int next_x = overlap->get_placed_x() + overlap->get_placed_x_size(); next_y = std::min(next_y, overlap->get_placed_y() + overlap->get_placed_y_size()); nassertr(next_x > x, false); x = next_x; diff --git a/pandatool/src/progbase/wordWrapStreamBuf.h b/pandatool/src/progbase/wordWrapStreamBuf.h index 0bc54b01f2..f1c54abfbb 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.h +++ b/pandatool/src/progbase/wordWrapStreamBuf.h @@ -25,7 +25,7 @@ class WordWrapStream; * Used by WordWrapStream to implement an ostream that flushes its output to * ProgramBase::show_text(). */ -class WordWrapStreamBuf : public std::streambuf { +class WordWrapStreamBuf final : public std::streambuf { public: WordWrapStreamBuf(WordWrapStream *owner, ProgramBase *program); virtual ~WordWrapStreamBuf(); diff --git a/pandatool/src/xfile/xFile.h b/pandatool/src/xfile/xFile.h index c53bdd8313..5dacb3c456 100644 --- a/pandatool/src/xfile/xFile.h +++ b/pandatool/src/xfile/xFile.h @@ -34,7 +34,7 @@ public: XFile(bool keep_names=false); ~XFile(); - virtual void clear(); + virtual void clear() final; bool read(Filename filename); bool read(std::istream &in, const std::string &filename = std::string()); diff --git a/pandatool/src/xfile/xFileDataDef.h b/pandatool/src/xfile/xFileDataDef.h index 3921619cdb..adcac50d1d 100644 --- a/pandatool/src/xfile/xFileDataDef.h +++ b/pandatool/src/xfile/xFileDataDef.h @@ -49,7 +49,7 @@ public: Type type, XFileTemplate *xtemplate = nullptr); virtual ~XFileDataDef(); - virtual void clear(); + virtual void clear() final; void add_array_def(const XFileArrayDef &array_def); INLINE Type get_data_type() const; diff --git a/pandatool/src/xfile/xFileTemplate.h b/pandatool/src/xfile/xFileTemplate.h index 5acc117072..d119a297b7 100644 --- a/pandatool/src/xfile/xFileTemplate.h +++ b/pandatool/src/xfile/xFileTemplate.h @@ -34,7 +34,7 @@ public: virtual bool is_template_def() const; - virtual void clear(); + virtual void clear() final; virtual void write_text(std::ostream &out, int indent_level) const; INLINE bool is_standard() const; diff --git a/pandatool/src/xfile/xParser.cxx.prebuilt b/pandatool/src/xfile/xParser.cxx.prebuilt index 0d12c68d03..03b2d8e6b3 100644 --- a/pandatool/src/xfile/xParser.cxx.prebuilt +++ b/pandatool/src/xfile/xParser.cxx.prebuilt @@ -1,20 +1,20 @@ /* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software Foundation, Inc. - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -27,7 +27,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -96,8 +96,8 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -static XFile *x_file = (XFile *)NULL; -static XFileNode *current_node = (XFileNode *)NULL; +static XFile *x_file = nullptr; +static XFileNode *current_node = nullptr; static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// @@ -113,8 +113,8 @@ x_init_parser(std::istream &in, const std::string &filename, XFile &file) { void x_cleanup_parser() { - x_file = (XFile *)NULL; - current_node = (XFileNode *)NULL; + x_file = nullptr; + current_node = nullptr; } @@ -1576,7 +1576,7 @@ yyreduce: #line 172 "xParser.yxx" { XFileTemplate *xtemplate = x_file->find_template((yyvsp[(1) - (3)].str)); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + (yyvsp[(1) - (3)].str)); } else { current_data_def = new XFileDataDef(x_file, (yyvsp[(2) - (3)].str), XFileDataDef::T_template, xtemplate); @@ -1700,7 +1700,7 @@ yyreduce: #line 237 "xParser.yxx" { XFileTemplate *xtemplate = x_file->find_template((yyvsp[(1) - (2)].str)); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + (yyvsp[(1) - (2)].str)); } else { current_data_def = new XFileDataDef(x_file, (yyvsp[(2) - (2)].str), XFileDataDef::T_template, xtemplate); @@ -1724,7 +1724,7 @@ yyreduce: #line 263 "xParser.yxx" { XFileNode *data_def = current_node->find_child((yyvsp[(1) - (1)].str)); - if (data_def == (XFileNode *)NULL) { + if (data_def == nullptr) { yyerror("Unknown identifier: " + (yyvsp[(1) - (1)].str)); } else { current_data_def->add_array_def(XFileArrayDef(DCAST(XFileDataDef, data_def))); @@ -1754,7 +1754,7 @@ yyreduce: #line 284 "xParser.yxx" { XFileTemplate *xtemplate = x_file->find_template((yyvsp[(1) - (1)].str)); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + (yyvsp[(1) - (1)].str)); } else { DCAST(XFileTemplate, current_node)->add_option(xtemplate); @@ -1768,7 +1768,7 @@ yyreduce: #line 293 "xParser.yxx" { XFileTemplate *xtemplate = x_file->find_template((yyvsp[(2) - (2)].guid)); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + (yyvsp[(1) - (2)].str)); } else { if (xtemplate->get_name() != (yyvsp[(1) - (2)].str)) { @@ -1823,11 +1823,11 @@ yyreduce: { XFileTemplate *xtemplate = x_file->find_template((yyvsp[(1) - (3)].str)); (yyval.u.node) = current_node; - - if (xtemplate == (XFileTemplate *)NULL) { + + if (xtemplate == nullptr) { yyerror("Unknown template: " + (yyvsp[(1) - (3)].str)); } else { - XFileDataNodeTemplate *templ = + XFileDataNodeTemplate *templ = new XFileDataNodeTemplate(x_file, (yyvsp[(2) - (3)].str), xtemplate); current_node->add_child(templ); current_node = templ; @@ -1841,7 +1841,7 @@ yyreduce: #line 363 "xParser.yxx" { if (current_node->is_exact_type(XFileDataNodeTemplate::get_class_type())) { - XFileDataNodeTemplate *current_template = + XFileDataNodeTemplate *current_template = DCAST(XFileDataNodeTemplate, current_node); current_template->finalize_parse_data(); } @@ -1876,7 +1876,7 @@ yyreduce: #line 391 "xParser.yxx" { if (current_node->is_exact_type(XFileDataNodeTemplate::get_class_type())) { - XFileDataNodeTemplate *current_template = + XFileDataNodeTemplate *current_template = DCAST(XFileDataNodeTemplate, current_node); current_template->add_parse_int((yyvsp[(1) - (1)].int_list)); } @@ -1889,7 +1889,7 @@ yyreduce: #line 399 "xParser.yxx" { if (current_node->is_exact_type(XFileDataNodeTemplate::get_class_type())) { - XFileDataNodeTemplate *current_template = + XFileDataNodeTemplate *current_template = DCAST(XFileDataNodeTemplate, current_node); current_template->add_parse_double((yyvsp[(1) - (1)].double_list)); } @@ -1902,7 +1902,7 @@ yyreduce: #line 407 "xParser.yxx" { if (current_node->is_exact_type(XFileDataNodeTemplate::get_class_type())) { - XFileDataNodeTemplate *current_template = + XFileDataNodeTemplate *current_template = DCAST(XFileDataNodeTemplate, current_node); current_template->add_parse_string((yyvsp[(1) - (2)].str)); } @@ -1923,7 +1923,7 @@ yyreduce: #line 438 "xParser.yxx" { XFileDataNodeTemplate *data_object = x_file->find_data_object((yyvsp[(1) - (1)].str)); - if (data_object == (XFileDataObject *)NULL) { + if (data_object == nullptr) { yyerror("Unknown data_object: " + (yyvsp[(1) - (1)].str)); } @@ -1937,7 +1937,7 @@ yyreduce: #line 447 "xParser.yxx" { XFileDataNodeTemplate *data_object = x_file->find_data_object((yyvsp[(2) - (2)].guid)); - if (data_object == (XFileDataObject *)NULL) { + if (data_object == nullptr) { yyerror("Unknown data_object: " + (yyvsp[(1) - (2)].str)); } else { if (data_object->get_name() != (yyvsp[(1) - (2)].str)) {