From 02e4e208ef989d5e9ee509fce224852bf9070f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 8 Dec 2023 13:33:45 +0100 Subject: [PATCH] Fix various GCC 13 warnings Fixes occurrences of `-Wtype-limits`, `-Wmaybe-uninitialized`, `-Wduplicated-branches`. --- core/ustring.cpp | 4 ++++ drivers/gles2/rasterizer_storage_gles2.h | 8 ++++---- drivers/gles3/rasterizer_storage_gles3.h | 6 +++--- modules/csg/csg.h | 4 ++-- modules/visual_script/visual_script.cpp | 6 +----- servers/physics/space_sw.cpp | 4 ++-- servers/physics_2d/space_2d_sw.cpp | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/ustring.cpp b/core/ustring.cpp index 9c13f0c5cd5..d5543aa05bb 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1460,7 +1460,11 @@ bool String::parse_utf8(const char *p_utf8, int p_len, bool p_skip_cr) { int skip = 0; while (ptrtmp != ptrtmp_limit && *ptrtmp) { if (skip == 0) { +#if CHAR_MIN == 0 + uint8_t c = *ptrtmp; +#else uint8_t c = *ptrtmp >= 0 ? *ptrtmp : uint8_t(256 + *ptrtmp); +#endif if (p_skip_cr && c == '\r') { ptrtmp++; diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 88f8d623cce..38a55c9b1e5 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -1214,10 +1214,10 @@ public: struct MipMaps { struct Size { - GLuint fbo; - GLuint color; - int width; - int height; + GLuint fbo = 0; + GLuint color = 0; + int width = 0; + int height = 0; }; Vector sizes; diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 20abfefc3a4..9f7d48035dc 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -1349,9 +1349,9 @@ public: struct Effects { struct MipMaps { struct Size { - GLuint fbo; - int width; - int height; + GLuint fbo = 0; + int width = 0; + int height = 0; }; Vector sizes; diff --git a/modules/csg/csg.h b/modules/csg/csg.h index 42d68af33bb..82d1d7fce47 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -160,7 +160,7 @@ struct CSGBrushOperation { }; struct Face2D { - int vertex_idx[3]; + int vertex_idx[3] = {}; }; Vector vertices; @@ -168,7 +168,7 @@ struct CSGBrushOperation { Plane plane; Transform to_2D; Transform to_3D; - float vertex_snap2; + float vertex_snap2 = 0.0; inline int _get_point_idx(const Vector2 &p_point); inline int _add_vertex(const Vertex2D &p_vertex); diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index c436810260d..37b5747c9f2 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1696,11 +1696,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p } next = node->sequence_outputs[output]; - if (next) { - VSDEBUG("GOT NEXT NODE - " + itos(next->get_id())); - } else { - VSDEBUG("GOT NEXT NODE - NULL"); - } + VSDEBUG("GOT NEXT NODE - " + (next ? itos(next->get_id()) : "NULL")); } if (flow_stack) { diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 535aa4437a7..34c9aa013af 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -115,8 +115,8 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto bool collided = false; Vector3 res_point, res_normal; - int res_shape; - const CollisionObjectSW *res_obj; + int res_shape = 0; + const CollisionObjectSW *res_obj = nullptr; real_t min_d = 1e10; for (int i = 0; i < amount; i++) { diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 13363aaff16..64b36ceb057 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -137,8 +137,8 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec bool collided = false; Vector2 res_point, res_normal; - int res_shape; - const CollisionObject2DSW *res_obj; + int res_shape = 0; + const CollisionObject2DSW *res_obj = nullptr; real_t min_d = 1e10; for (int i = 0; i < amount; i++) {