Fix errors and warnings

Former-commit-id: a3ba309633f198f82c1d0277d750d867cad4ba44
This commit is contained in:
Lynix
2015-11-12 00:29:10 +01:00
parent a26c979d84
commit 5d6e6b2d45
14 changed files with 55 additions and 30 deletions

View File

@@ -4,6 +4,7 @@
#include <Nazara/Network/Algorithm.hpp>
#include <Nazara/Core/Error.hpp>
#include <cstring>
#include <Nazara/Network/Debug.hpp>
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

View File

@@ -7,6 +7,7 @@
#include <Nazara/Core/StringStream.hpp>
#include <Nazara/Network/Algorithm.hpp>
#include <algorithm>
#include <limits>
#include <Nazara/Network/SystemSocket.hpp>
#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<unsigned int>::max();
unsigned int l0 = std::numeric_limits<unsigned int>::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;
}

View File

@@ -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);
}
}
}

View File

@@ -6,6 +6,7 @@
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Network/Win32/SocketImpl.hpp>
#include <cstring>
#include <Nazara/Network/Debug.hpp>
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;
}