Fix various GCC 13 warnings

Fixes occurrences of `-Wtype-limits`, `-Wmaybe-uninitialized`,
`-Wduplicated-branches`.
This commit is contained in:
Rémi Verschelde 2023-12-08 13:33:45 +01:00 committed by Relintai
parent 312a907ce7
commit 1c70f86950
5 changed files with 14 additions and 10 deletions

View File

@ -3161,7 +3161,11 @@ Error String::parse_utf8(const char *p_utf8, int p_len, bool p_skip_cr) {
int skip = 0; int skip = 0;
uint8_t c_start = 0; uint8_t c_start = 0;
while (ptrtmp != ptrtmp_limit && *ptrtmp) { while (ptrtmp != ptrtmp_limit && *ptrtmp) {
#if CHAR_MIN == 0
uint8_t c = *ptrtmp;
#else
uint8_t c = *ptrtmp >= 0 ? *ptrtmp : uint8_t(256 + *ptrtmp); uint8_t c = *ptrtmp >= 0 ? *ptrtmp : uint8_t(256 + *ptrtmp);
#endif
if (skip == 0) { if (skip == 0) {
if (p_skip_cr && c == '\r') { if (p_skip_cr && c == '\r') {

View File

@ -1087,10 +1087,10 @@ public:
struct MipMaps { struct MipMaps {
struct Size { struct Size {
GLuint fbo; GLuint fbo = 0;
GLuint color; GLuint color = 0;
int width; int width = 0;
int height; int height = 0;
}; };
Vector<Size> sizes; Vector<Size> sizes;

View File

@ -162,7 +162,7 @@ struct CSGBrushOperation {
}; };
struct Face2D { struct Face2D {
int vertex_idx[3]; int vertex_idx[3] = {};
}; };
Vector<Vertex2D> vertices; Vector<Vertex2D> vertices;
@ -170,7 +170,7 @@ struct CSGBrushOperation {
Plane plane; Plane plane;
Transform to_2D; Transform to_2D;
Transform to_3D; Transform to_3D;
float vertex_snap2; float vertex_snap2 = 0.0;
inline int _get_point_idx(const Vector2 &p_point); inline int _get_point_idx(const Vector2 &p_point);
inline int _add_vertex(const Vertex2D &p_vertex); inline int _add_vertex(const Vertex2D &p_vertex);

View File

@ -116,8 +116,8 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
bool collided = false; bool collided = false;
Vector3 res_point, res_normal; Vector3 res_point, res_normal;
int res_shape; int res_shape = 0;
const CollisionObjectSW *res_obj; const CollisionObjectSW *res_obj = nullptr;
real_t min_d = 1e10; real_t min_d = 1e10;
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {

View File

@ -138,8 +138,8 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec
bool collided = false; bool collided = false;
Vector2 res_point, res_normal; Vector2 res_point, res_normal;
int res_shape; int res_shape = 0;
const CollisionObject2DSW *res_obj; const CollisionObject2DSW *res_obj = nullptr;
real_t min_d = 1e10; real_t min_d = 1e10;
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {