From 5d6e6b2d4522cef8d6a8a6744e6193d60f604fba Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 12 Nov 2015 00:29:10 +0100 Subject: [PATCH] Fix errors and warnings Former-commit-id: a3ba309633f198f82c1d0277d750d867cad4ba44 --- SDK/src/NDK/Entity.cpp | 2 +- include/Nazara/Graphics/Billboard.inl | 4 ++-- include/Nazara/Network/Debug.hpp | 2 +- include/Nazara/Network/DebugOff.hpp | 2 +- include/Nazara/Network/IpAddress.inl | 23 ++++++++++++++-------- include/Nazara/Network/TcpServer.inl | 4 ++++ include/Nazara/Network/UdpSocket.inl | 4 ++++ src/Nazara/Core/String.cpp | 1 - src/Nazara/Graphics/Material.cpp | 2 -- src/Nazara/Network/Algorithm.cpp | 9 +++++---- src/Nazara/Network/IpAddress.cpp | 17 +++++++++++----- src/Nazara/Network/TcpClient.cpp | 6 +++++- src/Nazara/Network/Win32/IpAddressImpl.cpp | 5 +++-- src/Nazara/Renderer/Renderer.cpp | 4 ++-- 14 files changed, 55 insertions(+), 30 deletions(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index d26a8f953..42ecf36b1 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -12,9 +12,9 @@ namespace Ndk Entity::Entity(Entity&& entity) : m_components(std::move(entity.m_components)), m_handles(std::move(entity.m_handles)), - m_id(entity.m_id), m_componentBits(std::move(entity.m_componentBits)), m_systemBits(std::move(entity.m_systemBits)), + m_id(entity.m_id), m_world(entity.m_world), m_valid(entity.m_valid) { diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 4a8cde469..c9760d0d1 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -35,9 +35,9 @@ namespace Nz InstancedRenderable(billboard), m_color(billboard.m_color), m_material(billboard.m_material), - m_rotation(billboard.m_rotation), m_sinCos(billboard.m_sinCos), - m_size(billboard.m_size) + m_size(billboard.m_size), + m_rotation(billboard.m_rotation) { } diff --git a/include/Nazara/Network/Debug.hpp b/include/Nazara/Network/Debug.hpp index 458bcf548..0826a3ecc 100644 --- a/include/Nazara/Network/Debug.hpp +++ b/include/Nazara/Network/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_MODULENAME_MANAGE_MEMORY +#if NAZARA_NETWORK_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/Network/DebugOff.hpp b/include/Nazara/Network/DebugOff.hpp index 9ae8c8e69..dd45ac45c 100644 --- a/include/Nazara/Network/DebugOff.hpp +++ b/include/Nazara/Network/DebugOff.hpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp // On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_MODULENAME_MANAGE_MEMORY +#if NAZARA_NETWORK_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index f12361081..c9aab3065 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz @@ -13,31 +14,31 @@ namespace Nz } inline IpAddress::IpAddress(const IPv4& ip, UInt16 port) : - m_isValid(true), m_ipv4(ip), m_protocol(NetProtocol_IPv4), - m_port(port) + m_port(port), + m_isValid(true) { } - + inline IpAddress::IpAddress(const IPv6& ip, UInt16 port) : - m_isValid(true), m_ipv6(ip), m_protocol(NetProtocol_IPv6), - m_port(port) + m_port(port), + m_isValid(true) { } - + inline IpAddress::IpAddress(const UInt8& a, const UInt8& b, const UInt8& c, const UInt8& d, UInt16 port) : IpAddress(IPv4{a, b, c, d}, port) { } - + inline IpAddress::IpAddress(const UInt16& a, const UInt16& b, const UInt16& c, const UInt16& d, const UInt16& e, const UInt16& f, const UInt16& g, const UInt16& h, UInt16 port) : IpAddress(IPv6{a, b, c, d, e, f, g, h}, port) { } - + inline IpAddress::IpAddress(const char* address) { BuildFromAddress(address); @@ -116,6 +117,9 @@ namespace Nz // Each protocol has its variables to compare switch (first.m_protocol) { + case NetProtocol_Any: + break; + case NetProtocol_IPv4: { if (first.m_ipv4 != second.m_ipv4) @@ -162,6 +166,9 @@ namespace Nz // Compare IP (thanks to std::array comparison operator) switch (first.m_protocol) { + case NetProtocol_Any: + break; + case NetProtocol_IPv4: { if (first.m_ipv4 != second.m_ipv4) diff --git a/include/Nazara/Network/TcpServer.inl b/include/Nazara/Network/TcpServer.inl index 905320888..42092b41b 100644 --- a/include/Nazara/Network/TcpServer.inl +++ b/include/Nazara/Network/TcpServer.inl @@ -35,6 +35,10 @@ namespace Nz IpAddress any; switch (protocol) { + case NetProtocol_Any: + NazaraInternalError("Invalid protocol Any at this point"); + return SocketState_NotConnected; + case NetProtocol_IPv4: any = IpAddress::AnyIpV4; break; diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index a77aeca3b..fbfe7f6ab 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -29,6 +29,10 @@ namespace Nz IpAddress any; switch (m_protocol) { + case NetProtocol_Any: + NazaraInternalError("Invalid protocol Any at this point"); + return SocketState_NotConnected; + case NetProtocol_IPv4: any = IpAddress::AnyIpV4; break; diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index fc63ebe06..a8e462d5d 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -1912,7 +1912,6 @@ namespace Nz } else { - unsigned int newSize = m_sharedString->size + length; auto newString = std::make_shared(m_sharedString->size + length); char* ptr = newString->string.get(); diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 15e851c78..9d34c9995 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -724,8 +724,6 @@ namespace Nz return false; } - bool glsl140 = (OpenGL::GetGLSLVersion() >= 140); - // Basic shader { UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); diff --git a/src/Nazara/Network/Algorithm.cpp b/src/Nazara/Network/Algorithm.cpp index 628e9cf45..273169005 100644 --- a/src/Nazara/Network/Algorithm.cpp +++ b/src/Nazara/Network/Algorithm.cpp @@ -4,6 +4,7 @@ #include #include +#include #include namespace Nz @@ -173,14 +174,14 @@ namespace Nz addressPtr = savedPtr; // who knows how to parse ipv4? we do! - UInt8 result[16]; - bool isIPv6; - if (!ParseIPAddress(addressPtr, result, nullptr, &isIPv6, &addressPtr) || isIPv6) // must parse and must be ipv4 + UInt8 ipv4[16]; + bool ipv6; + if (!ParseIPAddress(addressPtr, ipv4, nullptr, &ipv6, &addressPtr) || ipv6) // must parse and must be ipv4 return false; // transfer addrlocal into the present location for (unsigned int j = 0; j < 4; ++j) - *(resultPtr++) = result[j]; + *(resultPtr++) = ipv4[j]; ++i; // pretend like we took another short, since the ipv4 effectively is two shorts mappedIPv4 = true; // remember how we got here for further validation later diff --git a/src/Nazara/Network/IpAddress.cpp b/src/Nazara/Network/IpAddress.cpp index 7dfe07056..473ce579f 100644 --- a/src/Nazara/Network/IpAddress.cpp +++ b/src/Nazara/Network/IpAddress.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #if defined(NAZARA_PLATFORM_WINDOWS) @@ -55,6 +56,9 @@ namespace Nz NazaraAssert(m_protocol <= NetProtocol_Max, "Protocol has value out of enum"); switch (m_protocol) { + case NetProtocol_Any: + break; + case NetProtocol_IPv4: return m_ipv4[0] == 127; @@ -69,12 +73,15 @@ namespace Nz String IpAddress::ToString() const { StringStream stream; - + if (m_isValid) { NazaraAssert(m_protocol <= NetProtocol_Max, "Protocol has value out of enum"); switch (m_protocol) { + case NetProtocol_Any: + break; + case NetProtocol_IPv4: for (unsigned int i = 0; i < 4; ++i) { @@ -89,8 +96,8 @@ namespace Nz // https://tools.ietf.org/html/rfc5952 // Find the longest zero sequence - int f0 = -1; - int l0 = -1; + unsigned int f0 = std::numeric_limits::max(); + unsigned int l0 = std::numeric_limits::max(); for (unsigned int i = 0; i < 8; ++i) { @@ -138,7 +145,7 @@ namespace Nz if (m_port != 0) stream << ':' << m_port; } - + return stream; } @@ -146,7 +153,7 @@ namespace Nz { String hostname; IpAddressImpl::ResolveAddress(address, &hostname, service, error); - + return hostname; } diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index ab825bb89..22d93c08e 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -218,6 +218,10 @@ namespace Nz { switch (m_state) { + case SocketState_Bound: + case SocketState_Resolving: + break; + case SocketState_Connected: return true; @@ -278,4 +282,4 @@ namespace Nz m_peerAddress = peerAddress; UpdateState(SocketState_Connected); } -} \ No newline at end of file +} diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 5715859ca..1a5de9ada 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace Nz @@ -64,7 +65,7 @@ namespace Nz if (service) service->Set(serviceBuffer.data()); } - + return result; } @@ -95,7 +96,7 @@ namespace Nz return IpAddress(rawIpV6[0], rawIpV6[1], rawIpV6[2], rawIpV6[3], rawIpV6[4], rawIpV6[5], rawIpV6[6], rawIpV6[7], ntohs(ipv6->sin6_port)); } } - + return IpAddress::Invalid; } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 23167dae9..7c2ba3459 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -1546,7 +1546,7 @@ namespace Nz glBindBuffer(OpenGL::BufferTarget[BufferType_Vertex], vertexBufferImpl->GetOpenGLID()); unsigned int bufferOffset = vertexBuffer->GetStartOffset(); - const VertexDeclaration* vertexDeclaration = vertexBuffer->GetVertexDeclaration(); + vertexDeclaration = vertexBuffer->GetVertexDeclaration(); unsigned int stride = vertexDeclaration->GetStride(); // On définit les bornes (une fois de plus selon l'itération) @@ -1934,4 +1934,4 @@ namespace Nz } unsigned int Renderer::s_moduleReferenceCounter = 0; -} \ No newline at end of file +}