From 96618cbb5b1e2bc63c4852ae1adc42772cca54aa Mon Sep 17 00:00:00 2001 From: SirLynix Date: Tue, 27 Jun 2023 19:31:24 +0200 Subject: [PATCH] Fix some warnings --- examples/PhysicsDemo/main.cpp | 1 - examples/Showcase/main.cpp | 2 +- include/Nazara/Core/StateMachine.hpp | 4 ++-- include/Nazara/Math/Frustum.inl | 1 - include/Nazara/Utility/Image.inl | 2 ++ src/Nazara/Graphics/Systems/RenderSystem.cpp | 6 +++--- src/Nazara/Platform/Window.cpp | 14 +++++++++++--- src/Nazara/Utility/IndexMapper.cpp | 7 ------- src/ShaderNode/Previews/QuadPreview.cpp | 4 +++- src/ShaderNode/Widgets/StructMemberEditDialog.cpp | 8 +++++--- tests/Std140Debug/main.cpp | 2 +- 11 files changed, 28 insertions(+), 23 deletions(-) diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index 76ca17a4a..27876d184 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -51,7 +51,6 @@ int main() return __LINE__; } - const Nz::Boxf& spaceshipAABB = spaceshipMesh->GetAABB(); std::shared_ptr gfxMesh = Nz::GraphicalMesh::BuildFromMesh(*spaceshipMesh); Nz::TextureSamplerInfo samplerInfo; diff --git a/examples/Showcase/main.cpp b/examples/Showcase/main.cpp index a26931eed..5c76942ff 100644 --- a/examples/Showcase/main.cpp +++ b/examples/Showcase/main.cpp @@ -351,7 +351,7 @@ int main() Nz::JoltRigidBody3D::StaticSettings floorSettings; floorSettings.geom = translatedFloorCollider; - auto& planeBody = floorEntity.emplace(physSytem.CreateRigidBody(floorSettings)); + floorEntity.emplace(physSytem.CreateRigidBody(floorSettings)); std::shared_ptr boxMeshGfx = Nz::GraphicalMesh::Build(Nz::Primitive::Box(Nz::Vector3f(0.5f, 0.5f, 0.5f)), meshPrimitiveParams); diff --git a/include/Nazara/Core/StateMachine.hpp b/include/Nazara/Core/StateMachine.hpp index b86b27e27..264a6539d 100644 --- a/include/Nazara/Core/StateMachine.hpp +++ b/include/Nazara/Core/StateMachine.hpp @@ -20,7 +20,7 @@ namespace Nz public: inline StateMachine(std::shared_ptr originalState); StateMachine(const StateMachine&) = delete; - inline StateMachine(StateMachine&& fsm) = default; + StateMachine(StateMachine&&) = default; inline ~StateMachine(); inline void ChangeState(std::shared_ptr state); @@ -35,7 +35,7 @@ namespace Nz inline bool Update(Time elapsedTime); - inline StateMachine& operator=(StateMachine&& fsm) = default; + StateMachine& operator=(StateMachine&& fsm) = default; StateMachine& operator=(const StateMachine&) = delete; private: diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 4fa591fd9..bb64af403 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -379,7 +379,6 @@ namespace Nz for (const auto& plane : m_planes) { bool outside = true; - std::size_t insidePoint = 0; for (std::size_t i = 0; i < pointCount; ++i) { // If at least one point is outside of the frustum, we're intersecting diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index 9538deb15..a9bbaab56 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -37,9 +37,11 @@ namespace Nz case ImageType::E1D: NazaraAssert(baseLayer == 0, "out of bounds"); NazaraAssert(layerCount <= 1, "out of bounds"); + [[fallthrough]]; case ImageType::E2D: NazaraAssert(baseLayer == 0, "out of bounds"); NazaraAssert(layerCount <= 1, "out of bounds"); + [[fallthrough]]; case ImageType::E3D: region.z = 0; region.depth = 1; diff --git a/src/Nazara/Graphics/Systems/RenderSystem.cpp b/src/Nazara/Graphics/Systems/RenderSystem.cpp index aa2dddbeb..68a1e6ff8 100644 --- a/src/Nazara/Graphics/Systems/RenderSystem.cpp +++ b/src/Nazara/Graphics/Systems/RenderSystem.cpp @@ -334,7 +334,7 @@ namespace Nz if (!gfx->IsVisible()) return; - for (std::size_t renderableIndex = 0; renderableIndex < LightComponent::MaxLightCount; ++renderableIndex) + for (std::size_t renderableIndex = 0; renderableIndex < GraphicsComponent::MaxRenderableCount; ++renderableIndex) { const auto& renderableEntry = gfx->GetRenderableEntry(renderableIndex); if (!renderableEntry.renderable) @@ -515,7 +515,7 @@ namespace Nz m_pipeline->UnregisterLight(lightEntity->lightIndices[lightIndex]); } } - m_newlyHiddenGfxEntities.clear(); + m_newlyHiddenLightEntities.clear(); // Register lights for newly visible entities for (LightEntity* lightEntity : m_newlyVisibleLightEntities) @@ -531,7 +531,7 @@ namespace Nz lightEntity->lightIndices[renderableIndex] = m_pipeline->RegisterLight(lightEntry.light.get(), lightEntry.renderMask); } } - m_newlyVisibleGfxEntities.clear(); + m_newlyVisibleLightEntities.clear(); //FIXME: Handle light visibility } diff --git a/src/Nazara/Platform/Window.cpp b/src/Nazara/Platform/Window.cpp index 5d08d1b40..412987d62 100644 --- a/src/Nazara/Platform/Window.cpp +++ b/src/Nazara/Platform/Window.cpp @@ -41,6 +41,11 @@ namespace Nz bool Window::Create(VideoMode mode, const std::string& title, WindowStyleFlags style) { +#ifdef NAZARA_COMPILER_MSVC +#pragma warning(push) +#pragma warning(disable:4701) //< uninitialized variable maybe used (position) +#endif + // If the window is already open, we keep its position bool opened = IsOpen(); Vector2i position; @@ -77,8 +82,11 @@ namespace Nz destroyOnFailure.Reset(); - m_eventHandler.Dispatch({ WindowEventType::Created }); + m_eventHandler.Dispatch({ { WindowEventType::Created } }); +#ifdef NAZARA_COMPILER_MSVC +#pragma warning(pop) +#endif return true; } @@ -100,7 +108,7 @@ namespace Nz m_closed = false; m_ownsWindow = false; - m_eventHandler.Dispatch({ WindowEventType::Created }); + m_eventHandler.Dispatch({ { WindowEventType::Created } }); return true; } @@ -109,7 +117,7 @@ namespace Nz { if (m_impl) { - m_eventHandler.Dispatch({ WindowEventType::Destruction }); + m_eventHandler.Dispatch({ { WindowEventType::Destruction } }); m_impl->Destroy(); m_impl.reset(); diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index dfbeb51c4..beecd6be2 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -12,13 +12,6 @@ namespace Nz { namespace NAZARA_ANONYMOUS_NAMESPACE { - UInt32 GetterSequential(const void* buffer, std::size_t i) - { - NazaraUnused(buffer); - - return static_cast(i); - } - UInt32 Getter8(const void* buffer, std::size_t i) { const UInt8* ptr = static_cast(buffer); diff --git a/src/ShaderNode/Previews/QuadPreview.cpp b/src/ShaderNode/Previews/QuadPreview.cpp index 8b252686d..8867e0d78 100644 --- a/src/ShaderNode/Previews/QuadPreview.cpp +++ b/src/ShaderNode/Previews/QuadPreview.cpp @@ -1,8 +1,10 @@ #include #include -PreviewValues QuadPreview::GetPreview(InputRole role, std::size_t roleIndex) const +PreviewValues QuadPreview::GetPreview(InputRole role, [[maybe_unused]] std::size_t roleIndex) const { + assert(roleIndex == 0); + if (role != InputRole::TexCoord) { PreviewValues dummy(1, 1); diff --git a/src/ShaderNode/Widgets/StructMemberEditDialog.cpp b/src/ShaderNode/Widgets/StructMemberEditDialog.cpp index dcf0d830f..66a261a0a 100644 --- a/src/ShaderNode/Widgets/StructMemberEditDialog.cpp +++ b/src/ShaderNode/Widgets/StructMemberEditDialog.cpp @@ -60,10 +60,12 @@ StructMemberInfo StructMemberEditDialog::GetMemberInfo() const StructMemberInfo inputInfo; inputInfo.name = m_memberName->text().toStdString(); - if (m_typeList->currentIndex() < PrimitiveTypeCount) - inputInfo.type = static_cast(m_typeList->currentIndex()); + std::size_t index = Nz::SafeCast(m_typeList->currentIndex()); + + if (index < PrimitiveTypeCount) + inputInfo.type = static_cast(index); else - inputInfo.type = static_cast(m_typeList->currentIndex() - PrimitiveTypeCount); + inputInfo.type = Nz::SafeCast(index - PrimitiveTypeCount); return inputInfo; } diff --git a/tests/Std140Debug/main.cpp b/tests/Std140Debug/main.cpp index 2eccaf09c..b1aafe9e6 100644 --- a/tests/Std140Debug/main.cpp +++ b/tests/Std140Debug/main.cpp @@ -151,7 +151,7 @@ int main() GLint dataSize; program.GetActiveUniformBlock(blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &dataSize); - if (fieldOffsets.GetAlignedSize() != dataSize) + if (fieldOffsets.GetAlignedSize() != std::size_t(dataSize)) std::cout << "size mismatch (computed " << fieldOffsets.GetAlignedSize() << ", reference has " << dataSize << ")" << std::endl;; if (computedOffsets.size() != uniformIndices.size())