Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some clang-tidy suggestions #97797

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "core/os/main_loop.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
#include "core/templates/vector.h"

template <typename T>
class TypedArray;
Expand Down
1 change: 0 additions & 1 deletion core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "core/io/marshalls.h"
#include "core/io/resource_uid.h"
#include "core/object/script_language.h"
#include "core/os/keyboard.h"
#include "core/templates/rb_set.h"
#include "core/variant/typed_array.h"
#include "core/variant/variant_parser.h"
Expand Down
4 changes: 2 additions & 2 deletions core/io/ip_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct IPAddress {
uint32_t field32[4];
};

bool valid;
bool wildcard;
bool valid = false;
bool wildcard = false;

protected:
void _parse_ipv6(const String &p_string);
Expand Down
10 changes: 5 additions & 5 deletions core/io/marshalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static inline unsigned int encode_uint32(uint32_t p_uint, uint8_t *p_arr) {
}

static inline unsigned int encode_float(float p_float, uint8_t *p_arr) {
MarshallFloat mf;
MarshallFloat mf{};
mf.f = p_float;
encode_uint32(mf.i, p_arr);

Expand All @@ -103,7 +103,7 @@ static inline unsigned int encode_uint64(uint64_t p_uint, uint8_t *p_arr) {
}

static inline unsigned int encode_double(double p_double, uint8_t *p_arr) {
MarshallDouble md;
MarshallDouble md{};
md.d = p_double;
encode_uint64(md.l, p_arr);

Expand All @@ -121,7 +121,7 @@ static inline unsigned int encode_uintr(uintr_t p_uint, uint8_t *p_arr) {
}

static inline unsigned int encode_real(real_t p_real, uint8_t *p_arr) {
MarshallReal mr;
MarshallReal mr{};
mr.r = p_real;
encode_uintr(mr.i, p_arr);

Expand Down Expand Up @@ -173,7 +173,7 @@ static inline uint32_t decode_uint32(const uint8_t *p_arr) {
}

static inline float decode_float(const uint8_t *p_arr) {
MarshallFloat mf;
MarshallFloat mf{};
mf.i = decode_uint32(p_arr);
return mf.f;
}
Expand All @@ -192,7 +192,7 @@ static inline uint64_t decode_uint64(const uint8_t *p_arr) {
}

static inline double decode_double(const uint8_t *p_arr) {
MarshallDouble md;
MarshallDouble md{};
md.l = decode_uint64(p_arr);
return md.d;
}
Expand Down
2 changes: 1 addition & 1 deletion core/math/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ struct [[nodiscard]] Color {
// bit and the first 8 mantissa bits to be shifted down to the low 9 bits
// of the mantissa, rounding the truncated bits.
union {
float f;
float f = 0.0f;
int32_t i;
} R, G, B, E;

Expand Down
16 changes: 8 additions & 8 deletions core/math/math_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Math {
union {
uint64_t u;
double f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
// (unsigned)(0x7ff0000000000001 >> 32) : 0x7ff00000
return ((((unsigned)(ieee754.u >> 32) & 0x7fffffff) + ((unsigned)ieee754.u != 0)) > 0x7ff00000);
Expand All @@ -152,7 +152,7 @@ class Math {
union {
uint32_t u;
float f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
// -----------------------------------
// (single-precision floating-point)
Expand All @@ -176,7 +176,7 @@ class Math {
union {
uint64_t u;
double f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
((unsigned)ieee754.u == 0);
Expand All @@ -193,7 +193,7 @@ class Math {
union {
uint32_t u;
float f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
return (ieee754.u & 0x7fffffff) == 0x7f800000;
#else
Expand Down Expand Up @@ -624,7 +624,7 @@ class Math {
union {
float f;
uint32_t i;
} u;
} u = {};

u.f = g;
u.i &= 2147483647u;
Expand All @@ -635,7 +635,7 @@ class Math {
union {
double d;
uint64_t i;
} u;
} u = {};
u.d = g;
u.i &= (uint64_t)9223372036854775807ll;
return u.d;
Expand Down Expand Up @@ -682,7 +682,7 @@ class Math {
union {
uint32_t u32;
float f32;
} u;
} u = {};

u.u32 = halfbits_to_floatbits(*h);
return u.f32;
Expand All @@ -696,7 +696,7 @@ class Math {
union {
float fv;
uint32_t ui;
} ci;
} ci = {};
ci.fv = f;

uint32_t x = ci.ui;
Expand Down
4 changes: 2 additions & 2 deletions core/object/callable_method_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

class CallableCustomMethodPointerBase : public CallableCustom {
uint32_t *comp_ptr = nullptr;
uint32_t comp_size;
uint32_t h;
uint32_t comp_size = 0U;
uint32_t h = 0U;
#ifdef DEBUG_METHODS_ENABLED
const char *text = "";
#endif
Expand Down
2 changes: 1 addition & 1 deletion core/object/message_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class CallQueue {
bool is_flushing() const;
int get_max_buffer_usage() const;

CallQueue(Allocator *p_custom_allocator = 0, uint32_t p_max_pages = 8192, const String &p_error_text = String());
CallQueue(Allocator *p_custom_allocator = nullptr, uint32_t p_max_pages = 8192, const String &p_error_text = String());
virtual ~CallQueue();
};

Expand Down
8 changes: 4 additions & 4 deletions core/templates/hashfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_one_32(uint32_t p_in, uint32_t p_see

static _FORCE_INLINE_ uint32_t hash_murmur3_one_float(float p_in, uint32_t p_seed = HASH_MURMUR3_SEED) {
union {
float f;
float f = { 0.0f };
uint32_t i;
} u;

Expand All @@ -151,7 +151,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_one_64(uint64_t p_in, uint32_t p_see

static _FORCE_INLINE_ uint32_t hash_murmur3_one_double(double p_in, uint32_t p_seed = HASH_MURMUR3_SEED) {
union {
double d;
double d = { 0.0 };
uint64_t i;
} u;

Expand Down Expand Up @@ -239,7 +239,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_buffer(const void *key, int length,

static _FORCE_INLINE_ uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev = 5381) {
union {
double d;
double d = { 0.0 };
uint64_t i;
} u;

Expand Down Expand Up @@ -268,7 +268,7 @@ static _FORCE_INLINE_ uint32_t hash_make_uint32_t(T p_in) {

static _FORCE_INLINE_ uint64_t hash_djb2_one_float_64(double p_in, uint64_t p_prev = 5381) {
union {
double d;
double d = { 0.0 };
uint64_t i;
} u;

Expand Down
2 changes: 1 addition & 1 deletion core/templates/safe_refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SafeNumeric {
};

class SafeFlag {
std::atomic_bool flag;
std::atomic_bool flag = false;

static_assert(std::atomic_bool::is_always_lock_free);

Expand Down
3 changes: 1 addition & 2 deletions core/variant/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ class Variant {
static void unregister_types();

Variant(const Variant &p_variant);
_FORCE_INLINE_ Variant() :
type(NIL) {}
_FORCE_INLINE_ Variant() {}
_FORCE_INLINE_ ~Variant() {
clear();
}
Expand Down
Loading