cleanup: Fix assorted issues uncovered by clang-tidy

This commit is contained in:
rdb 2023-02-12 16:40:56 +01:00
parent 00f68fb8a5
commit 5e26aae1ff
74 changed files with 183 additions and 173 deletions

View File

@ -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;

View File

@ -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
}

View File

@ -24,10 +24,13 @@
#ifdef PHAVE_UTIME_H
#include <utime.h>
#endif
// We assume we have these too.
#ifndef _WIN32
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#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
}

View File

@ -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();

View File

@ -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 };

View File

@ -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;

View File

@ -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";

View File

@ -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

View File

@ -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) \

View File

@ -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::

View File

@ -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;

View File

@ -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;
}
/**

View File

@ -29,7 +29,7 @@
#include <AL/alc.h>
#endif
class EXPCL_OPENAL_AUDIO OpenALAudioSound : public AudioSound {
class EXPCL_OPENAL_AUDIO OpenALAudioSound final : public AudioSound {
friend class OpenALAudioManager;
public:

View File

@ -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:

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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,

View File

@ -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;
}
}

View File

@ -1403,7 +1403,7 @@ ostream &operator << (ostream &out, EggGroup::CollideFlags t) {
}
if (bits & EggGroup::CF_level) {
out << space << "level";
space = " ";
//space = " ";
}
return out;
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -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";
}
}

View File

@ -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);

View File

@ -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 &copy) :
OdeWorld::
~OdeWorld() {
if (odeworld_cat.is_debug()) {
odeworld_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n";
odeworld_cat.debug() << "~OdeWorld(" << _id << ")" << "\n";
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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<Curveseg> _segs;

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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);

View File

@ -106,7 +106,7 @@ output(std::ostream &out) const {
}
if ((_mode & M_better) != 0) {
out << sep << "better";
sep = '|';
//sep = '|';
}
}

View File

@ -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";
}

View File

@ -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.

View File

@ -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()) {

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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();

View File

@ -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();

View File

@ -64,7 +64,6 @@ private:
const PipelineCycler<CycleDataType> *_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;

View File

@ -56,7 +56,6 @@ private:
const PipelineCycler<CycleDataType> *_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;

View File

@ -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;

View File

@ -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));
}
}
}

View File

@ -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

View File

@ -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);

View File

@ -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 )

View File

@ -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;

View File

@ -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.

View File

@ -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) {

View File

@ -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 {

View File

@ -15,10 +15,10 @@
#define GTKSTATSCHARTMENU_H
#include "pandatoolbase.h"
#include "gtkStatsMonitor.h"
#include <gtk/gtk.h>
class GtkStatsMonitor;
class PStatView;
class PStatViewLevel;

View File

@ -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);

View File

@ -15,6 +15,7 @@
#define GTKSTATSLABEL_H
#include "pandatoolbase.h"
#include "luse.h"
#include <gtk/gtk.h>
#include <cairo.h>

View File

@ -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);

View File

@ -16,7 +16,6 @@
#include "pandatoolbase.h"
#include "gtkStatsGraph.h"
#include "pStatMonitor.h"
#include "pointerTo.h"
#include "pset.h"
@ -25,6 +24,7 @@
#include <gtk/gtk.h>
class GtkStatsGraph;
class GtkStatsServer;
class GtkStatsChartMenu;

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

@ -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());

View File

@ -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;

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/>. */
@ -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)) {