From 6d133e1bcc82c8646e0f94132a7e2cf09c840745 Mon Sep 17 00:00:00 2001 From: JosiahWI Date: Thu, 11 Nov 2021 15:53:46 -0600 Subject: [PATCH] Fix various GCC warnings - fix overload hiding - handle missing enumeration values in switch - remove extraenous semicolons - always have defaults in color converter switch - fix root cause of stringop warning --- include/irrString.h | 6 ++++-- source/Irrlicht/CColorConverter.cpp | 17 ++++++----------- source/Irrlicht/CIrrDeviceLinux.cpp | 2 +- source/Irrlicht/COpenGLDriver.h | 3 +++ source/Irrlicht/CSceneManager.cpp | 3 +++ source/Irrlicht/CSkinnedMesh.cpp | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/irrString.h b/include/irrString.h index 3178c396..f454aed4 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -920,8 +920,10 @@ public: if ((length+begin) > size()) length = size()-begin; + // accounting for null terminator. + s32 substrAllocLength = length + 1; string o; - o.reserve(length+1); + o.reserve(substrAllocLength); if ( !make_lower ) { @@ -934,7 +936,7 @@ public: o.array[i] = locale_lower ( array[i+begin] ); } - o.array[length] = 0; + o.array[substrAllocLength - 1] = 0; o.used = length + 1; return o; diff --git a/source/Irrlicht/CColorConverter.cpp b/source/Irrlicht/CColorConverter.cpp index f1e54117..9f9b48e3 100644 --- a/source/Irrlicht/CColorConverter.cpp +++ b/source/Irrlicht/CColorConverter.cpp @@ -760,10 +760,9 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN IRR_CASE_IIMAGE_COMPRESSED_FORMAT os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); break; -#ifndef _DEBUG + default: break; -#endif } break; case ECF_R5G6B5: @@ -784,10 +783,9 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN IRR_CASE_IIMAGE_COMPRESSED_FORMAT os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); break; -#ifndef _DEBUG + default: break; -#endif } break; case ECF_A8R8G8B8: @@ -808,10 +806,9 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN IRR_CASE_IIMAGE_COMPRESSED_FORMAT os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); break; -#ifndef _DEBUG + default: break; -#endif } break; case ECF_R8G8B8: @@ -832,19 +829,17 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN IRR_CASE_IIMAGE_COMPRESSED_FORMAT os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); break; -#ifndef _DEBUG + default: break; -#endif } break; IRR_CASE_IIMAGE_COMPRESSED_FORMAT os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); break; -#ifndef _DEBUG + default: - break; -#endif + break; } } diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp index c23a02b7..c4f8d4e7 100644 --- a/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/source/Irrlicht/CIrrDeviceLinux.cpp @@ -102,7 +102,7 @@ namespace #if defined(_IRR_LINUX_X11_XINPUT2_) int XI_EXTENSIONS_OPCODE; #endif -}; +} namespace irr { diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index 8b2616e1..281605fb 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -148,6 +148,9 @@ namespace video const core::rect& sourceRect, const core::rect* clipRect = 0, const video::SColor* const colors = 0, bool useAlphaChannelOfTexture = false) _IRR_OVERRIDE_; + // Explicitly bring in base class methods, otherwise + // this overload would hide them. + using CNullDriver::draw2DImage; virtual void draw2DImage(const video::ITexture* texture, u32 layer, bool flip); //! draws a set of 2d images, using a color and the alpha channel of the diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index 849b4e33..3223f4e0 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -607,6 +607,9 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDE taken = 1; } + // as of yet unused + case ESNRP_LIGHT: + case ESNRP_SHADOW: case ESNRP_NONE: // ignore this one break; } diff --git a/source/Irrlicht/CSkinnedMesh.cpp b/source/Irrlicht/CSkinnedMesh.cpp index 31b84508..eb9fb272 100644 --- a/source/Irrlicht/CSkinnedMesh.cpp +++ b/source/Irrlicht/CSkinnedMesh.cpp @@ -82,7 +82,7 @@ namespace { return a.rotation == b.rotation; } -}; +} namespace irr {