Skip to content

Commit de4c977

Browse files
committed
Fix more issues found by cppcheck.
1 parent f4b0c7a commit de4c977

File tree

63 files changed

+261
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+261
-268
lines changed

core/debugger/remote_debugger.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class RemoteDebugger::PerformanceProfiler : public EngineProfiler {
169169
EngineDebugger::get_singleton()->send_message("performance:profile_frame", arr);
170170
}
171171

172-
PerformanceProfiler(Object *p_performance) {
172+
explicit PerformanceProfiler(Object *p_performance) {
173173
performance = p_performance;
174174
}
175175
};

core/debugger/remote_debugger.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class RemoteDebugger : public EngineDebugger {
108108
void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, bool p_editor_notify, ErrorHandlerType p_type);
109109
void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false);
110110

111-
RemoteDebugger(Ref<RemoteDebuggerPeer> p_peer);
111+
explicit RemoteDebugger(Ref<RemoteDebuggerPeer> p_peer);
112112
~RemoteDebugger();
113113
};
114114

core/extension/native_extension.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class NativeExtensionMethodBind : public MethodBind {
4949
bool vararg;
5050

5151
protected:
52-
virtual Variant::Type _gen_argument_type(int p_arg) const {
52+
virtual Variant::Type _gen_argument_type(int p_arg) const override {
5353
return Variant::Type(get_argument_type_func(method_userdata, p_arg));
5454
}
55-
virtual PropertyInfo _gen_argument_type_info(int p_arg) const {
55+
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
5656
GDNativePropertyInfo pinfo;
5757
get_argument_info_func(method_userdata, p_arg, &pinfo);
5858
PropertyInfo ret;
@@ -66,11 +66,13 @@ class NativeExtensionMethodBind : public MethodBind {
6666
}
6767

6868
public:
69-
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const {
69+
#ifdef DEBUG_METHODS_ENABLED
70+
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
7071
return GodotTypeInfo::Metadata(get_argument_metadata_func(method_userdata, p_arg));
7172
}
73+
#endif
7274

73-
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
75+
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override {
7476
Variant ret;
7577
GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance();
7678
GDNativeCallError ce{ GDNATIVE_CALL_OK, 0, 0 };
@@ -80,16 +82,16 @@ class NativeExtensionMethodBind : public MethodBind {
8082
r_error.expected = ce.expected;
8183
return ret;
8284
}
83-
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) {
85+
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override {
8486
ERR_FAIL_COND_MSG(vararg, "Vararg methods don't have ptrcall support. This is most likely an engine bug.");
8587
GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance();
8688
ptrcall_func(method_userdata, extension_instance, (const GDNativeTypePtr *)p_args, (GDNativeTypePtr)r_ret);
8789
}
8890

89-
virtual bool is_vararg() const {
91+
virtual bool is_vararg() const override {
9092
return false;
9193
}
92-
NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) {
94+
explicit NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) {
9395
method_userdata = p_method_info->method_userdata;
9496
call_func = p_method_info->call_func;
9597
ptrcall_func = p_method_info->ptrcall_func;

core/io/file_access_pack.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PackedData {
9393

9494
PathMD5() {}
9595

96-
PathMD5(const Vector<uint8_t> &p_buf) {
96+
explicit PathMD5(const Vector<uint8_t> &p_buf) {
9797
a = *((uint64_t *)&p_buf[0]);
9898
b = *((uint64_t *)&p_buf[8]);
9999
}

core/io/logger.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Logger {
6767
*/
6868
class StdLogger : public Logger {
6969
public:
70-
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
70+
virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0;
7171
virtual ~StdLogger() {}
7272
};
7373

@@ -87,19 +87,19 @@ class RotatedFileLogger : public Logger {
8787
void rotate_file();
8888

8989
public:
90-
RotatedFileLogger(const String &p_base_path, int p_max_files = 10);
90+
explicit RotatedFileLogger(const String &p_base_path, int p_max_files = 10);
9191

92-
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
92+
virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0;
9393
};
9494

9595
class CompositeLogger : public Logger {
9696
Vector<Logger *> loggers;
9797

9898
public:
99-
CompositeLogger(Vector<Logger *> p_loggers);
99+
explicit CompositeLogger(Vector<Logger *> p_loggers);
100100

101-
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
102-
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR);
101+
virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0;
102+
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR) override;
103103

104104
void add_logger(Logger *p_logger);
105105

core/io/resource.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
257257
List<PropertyInfo> plist;
258258
get_property_list(&plist);
259259

260-
Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class());
260+
Ref<Resource> r = static_cast<Resource *>(ClassDB::instantiate(get_class()));
261261
ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
262262

263263
for (const PropertyInfo &E : plist) {

core/math/convex_hull.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ class ConvexHullInternal {
509509
Face() {
510510
}
511511

512-
void init(Vertex *p_a, Vertex *p_b, Vertex *p_c) {
512+
void init(Vertex *p_a, const Vertex *p_b, const Vertex *p_c) {
513513
nearby_vertex = p_a;
514514
origin = p_a->point;
515515
dir0 = *p_b - *p_a;
@@ -614,7 +614,7 @@ class ConvexHullInternal {
614614

615615
static Orientation get_orientation(const Edge *p_prev, const Edge *p_next, const Point32 &p_s, const Point32 &p_t);
616616
Edge *find_max_angle(bool p_ccw, const Vertex *p_start, const Point32 &p_s, const Point64 &p_rxs, const Point64 &p_ssxrxs, Rational64 &p_min_cot);
617-
void find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, Vertex *p_stop0, Vertex *p_stop1);
617+
void find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, const Vertex *p_stop0, const Vertex *p_stop1);
618618

619619
Edge *new_edge_pair(Vertex *p_from, Vertex *p_to);
620620

@@ -1189,7 +1189,7 @@ ConvexHullInternal::Edge *ConvexHullInternal::find_max_angle(bool p_ccw, const V
11891189
return min_edge;
11901190
}
11911191

1192-
void ConvexHullInternal::find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, Vertex *p_stop0, Vertex *p_stop1) {
1192+
void ConvexHullInternal::find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, const Vertex *p_stop0, const Vertex *p_stop1) {
11931193
Edge *start0 = p_e0;
11941194
Edge *start1 = p_e1;
11951195
Point32 et0 = start0 ? start0->target->point : p_c0->point;

core/math/geometry_3d.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,8 @@ Vector<Vector3> Geometry3D::compute_convex_mesh_points(const Plane *p_planes, in
904904
/* dt of 1d function using squared distance */
905905
static void edt(float *f, int stride, int n) {
906906
float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1));
907-
int *v = (int *)&(d[n]);
908-
float *z = (float *)&v[n];
907+
int *v = reinterpret_cast<int *>(&(d[n]));
908+
float *z = reinterpret_cast<float *>(&v[n]);
909909

910910
int k = 0;
911911
v[0] = 0;

core/math/math_funcs.h

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class Math {
103103
static _ALWAYS_INLINE_ double log(double p_x) { return ::log(p_x); }
104104
static _ALWAYS_INLINE_ float log(float p_x) { return ::logf(p_x); }
105105

106+
static _ALWAYS_INLINE_ double log1p(double p_x) { return ::log1p(p_x); }
107+
static _ALWAYS_INLINE_ float log1p(float p_x) { return ::log1pf(p_x); }
108+
106109
static _ALWAYS_INLINE_ double log2(double p_x) { return ::log2(p_x); }
107110
static _ALWAYS_INLINE_ float log2(float p_x) { return ::log2f(p_x); }
108111

0 commit comments

Comments
 (0)