diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-10-07 11:07:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-07 11:07:13 +0200 |
commit | bf6dcb91059c7cb59771cbff23364612309193a4 (patch) | |
tree | 5819ae11fc608a6d2c4bbeb0df73d7bd7dd02d18 /core | |
parent | eae742312f757ceb8b10ef3d343733e764a9c36a (diff) | |
parent | 3e9740ac93f291f9576f1f8d87ac07f7bd27b82a (diff) |
Merge pull request #22722 from akien-mga/fix-warnings
Fix more "may be used initialized" warnings from GCC 7
Diffstat (limited to 'core')
-rw-r--r-- | core/cowdata.h | 5 | ||||
-rw-r--r-- | core/image.cpp | 7 | ||||
-rw-r--r-- | core/math/face3.cpp | 9 |
3 files changed, 13 insertions, 8 deletions
diff --git a/core/cowdata.h b/core/cowdata.h index 9e75d4ed55..54ece4c856 100644 --- a/core/cowdata.h +++ b/core/cowdata.h @@ -87,7 +87,10 @@ private: #if defined(_add_overflow) && defined(_mul_overflow) size_t o; size_t p; - if (_mul_overflow(p_elements, sizeof(T), &o)) return false; + if (_mul_overflow(p_elements, sizeof(T), &o)) { + *out = 0; + return false; + } *out = next_power_of_2(o); if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here return true; diff --git a/core/image.cpp b/core/image.cpp index 3d85bdd345..172f5e517a 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1473,7 +1473,8 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma void Image::create(const char **p_xpm) { - int size_width, size_height; + int size_width = 0; + int size_height = 0; int pixelchars = 0; mipmaps = false; bool has_alpha = false; @@ -1489,8 +1490,8 @@ void Image::create(const char **p_xpm) { int line = 0; HashMap<String, Color> colormap; - int colormap_size; - uint32_t pixel_size; + int colormap_size = 0; + uint32_t pixel_size = 0; PoolVector<uint8_t>::Write w; while (status != DONE) { diff --git a/core/math/face3.cpp b/core/math/face3.cpp index aa46fde7f7..8366137131 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -202,11 +202,12 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const { { \ real_t aabb_min = p_aabb.position.m_ax; \ real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \ - real_t tri_min, tri_max; \ - for (int i = 0; i < 3; i++) { \ - if (i == 0 || vertex[i].m_ax > tri_max) \ + real_t tri_min = vertex[0].m_ax; \ + real_t tri_max = vertex[0].m_ax; \ + for (int i = 1; i < 3; i++) { \ + if (vertex[i].m_ax > tri_max) \ tri_max = vertex[i].m_ax; \ - if (i == 0 || vertex[i].m_ax < tri_min) \ + if (vertex[i].m_ax < tri_min) \ tri_min = vertex[i].m_ax; \ } \ \ |