Fix some clang-tidy suggestions

This commit is contained in:
Pablo Andres Fuente 2024-10-04 00:57:22 -03:00
parent 5ccbf6e4c7
commit df5a96e733
11 changed files with 25 additions and 28 deletions

View file

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

View file

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

View file

@ -41,8 +41,8 @@ private:
uint32_t field32[4];
};
bool valid;
bool wildcard;
bool valid = false;
bool wildcard = false;
protected:
void _parse_ipv6(const String &p_string);

View file

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

View file

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

View file

@ -136,7 +136,7 @@ public:
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);
@ -152,7 +152,7 @@ public:
union {
uint32_t u;
float f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
// -----------------------------------
// (single-precision floating-point)
@ -176,7 +176,7 @@ public:
union {
uint64_t u;
double f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
((unsigned)ieee754.u == 0);
@ -193,7 +193,7 @@ public:
union {
uint32_t u;
float f;
} ieee754;
} ieee754 = {};
ieee754.f = p_val;
return (ieee754.u & 0x7fffffff) == 0x7f800000;
#else
@ -624,7 +624,7 @@ public:
union {
float f;
uint32_t i;
} u;
} u = {};
u.f = g;
u.i &= 2147483647u;
@ -635,7 +635,7 @@ public:
union {
double d;
uint64_t i;
} u;
} u = {};
u.d = g;
u.i &= (uint64_t)9223372036854775807ll;
return u.d;
@ -682,7 +682,7 @@ public:
union {
uint32_t u32;
float f32;
} u;
} u = {};
u.u32 = halfbits_to_floatbits(*h);
return u.f32;
@ -696,7 +696,7 @@ public:
union {
float fv;
uint32_t ui;
} ci;
} ci = {};
ci.fv = f;
uint32_t x = ci.ui;

View file

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

View file

@ -153,7 +153,7 @@ public:
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();
};

View file

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

View file

@ -152,7 +152,7 @@ public:
};
class SafeFlag {
std::atomic_bool flag;
std::atomic_bool flag = false;
static_assert(std::atomic_bool::is_always_lock_free);

View file

@ -814,8 +814,7 @@ public:
static void unregister_types();
Variant(const Variant &p_variant);
_FORCE_INLINE_ Variant() :
type(NIL) {}
_FORCE_INLINE_ Variant() {}
_FORCE_INLINE_ ~Variant() {
clear();
}