DEV9: Warning fixes for clang-cl

This commit is contained in:
Stenzek 2022-12-25 15:57:09 +10:00 committed by refractionpcsx2
parent c4345f9a85
commit a978abb523
14 changed files with 50 additions and 50 deletions

View File

@ -57,11 +57,11 @@ namespace InternalServers
void DHCP_Server::Init(ifaddrs* adapter, IP_Address ipOverride, IP_Address subnetOverride, IP_Address gatewayOverride)
#endif
{
netmask = {0};
gateway = {0};
dns1 = {0};
dns2 = {0};
broadcastIP = {0};
netmask = {};
gateway = {};
dns1 = {};
dns2 = {};
broadcastIP = {};
if (ipOverride.integer != 0)
ps2IP = ipOverride;
@ -88,7 +88,7 @@ namespace InternalServers
dns1 = *(IP_Address*)EmuConfig.DEV9.DNS1;
break;
case Pcsx2Config::DEV9Options::DnsMode::Internal:
dns1 = {192, 0, 2, 1};
dns1 = {{{192, 0, 2, 1}}};
break;
default:
break;
@ -100,7 +100,7 @@ namespace InternalServers
dns2 = *(IP_Address*)EmuConfig.DEV9.DNS2;
break;
case Pcsx2Config::DEV9Options::DnsMode::Internal:
dns2 = {192, 0, 2, 1};
dns2 = {{{192, 0, 2, 1}}};
break;
default:
break;
@ -188,7 +188,7 @@ namespace InternalServers
//no value for DNS1, but we have a value for DNS2
//set DNS1 to DNS2 and zero DNS2
dns1 = dns2;
dns2 = {0, 0, 0, 0};
dns2 = {};
}
}

View File

@ -41,9 +41,9 @@ namespace InternalServers
private:
std::function<void()> callback;
PacketReader::IP::IP_Address dns1{0};
PacketReader::IP::IP_Address dns2{0};
PacketReader::IP::IP_Address netmask{0};
PacketReader::IP::IP_Address dns1{};
PacketReader::IP::IP_Address dns2{};
PacketReader::IP::IP_Address netmask{};
SimpleQueue<PacketReader::IP::UDP::UDP_Packet*> recvBuff;
@ -53,9 +53,9 @@ namespace InternalServers
DHCP_Server(std::function<void()> receivedcallback);
#ifdef _WIN32
void Init(PIP_ADAPTER_ADDRESSES adapter, PacketReader::IP::IP_Address ipOverride = {0}, PacketReader::IP::IP_Address subnetOverride = {0}, PacketReader::IP::IP_Address gatewayOvveride = {0});
void Init(PIP_ADAPTER_ADDRESSES adapter, PacketReader::IP::IP_Address ipOverride = {}, PacketReader::IP::IP_Address subnetOverride = {}, PacketReader::IP::IP_Address gatewayOvveride = {});
#elif defined(__POSIX__)
void Init(ifaddrs* adapter, PacketReader::IP::IP_Address ipOverride = {0}, PacketReader::IP::IP_Address subnetOverride = {0}, PacketReader::IP::IP_Address gatewayOvveride = {0});
void Init(ifaddrs* adapter, PacketReader::IP::IP_Address ipOverride = {}, PacketReader::IP::IP_Address subnetOverride = {}, PacketReader::IP::IP_Address gatewayOvveride = {});
#endif
PacketReader::IP::UDP::UDP_Packet* Recv();

View File

@ -58,7 +58,7 @@ namespace InternalServers
//See https://en.cppreference.com/w/cpp/container#Thread_safety
//Different elements in the same container can be modified concurrently by different threads
for (size_t i = 0; i < dnsQuestions.size(); i++)
answers[dnsQuestions[i]] = {0};
answers[dnsQuestions[i]] = {};
}
int DNS_Server::DNS_State::AddAnswer(const std::string& answer, IP_Address address)
@ -101,7 +101,7 @@ namespace InternalServers
void DNS_Server::Init(ifaddrs* adapter)
#endif
{
localhostIP = {127, 0, 0, 1};
localhostIP = {{{127, 0, 0, 1}}};
//Find IPv4 Address
std::optional<IP_Address> adapterIP = AdapterUtils::GetAdapterIP(adapter);
@ -220,7 +220,7 @@ namespace InternalServers
if (ans.integer != 0)
{
//TODO, might not be effective on pcap
const IP_Address local{127, 0, 0, 1};
const IP_Address local{{{127, 0, 0, 1}}};
if (ans == local)
ans = localhostIP;

View File

@ -68,7 +68,7 @@ namespace InternalServers
std::function<void()> callback;
PacketReader::IP::IP_Address localhostIP{127, 0, 0, 1};
PacketReader::IP::IP_Address localhostIP{{{127, 0, 0, 1}}};
std::unordered_map<std::string, PacketReader::IP::IP_Address> hosts;
std::atomic<int> outstandingQueries{0};
SimpleQueue<PacketReader::IP::UDP::UDP_Packet*> dnsQueue;

View File

@ -55,8 +55,8 @@ namespace PacketReader::IP
u16 checksum;
public:
IP_Address sourceIP{0};
IP_Address destinationIP{0};
IP_Address sourceIP{};
IP_Address destinationIP{};
std::vector<IPOption*> options;
private:

View File

@ -44,7 +44,7 @@ namespace PacketReader::IP::UDP::DHCP
class DHCPopSubnet : public BaseOption
{
public:
IP_Address subnetMask{0};
IP_Address subnetMask{};
DHCPopSubnet(IP_Address mask);
DHCPopSubnet(u8* data, int offset); //Offset will include Kind and Len
@ -139,7 +139,7 @@ namespace PacketReader::IP::UDP::DHCP
class DHCPopBCIP : public BaseOption //The IP to send broadcasts to
{
public:
IP_Address broadcastIP{0};
IP_Address broadcastIP{};
DHCPopBCIP(IP_Address data);
DHCPopBCIP(u8* data, int offset); //Offset will include Kind and Len
@ -191,7 +191,7 @@ namespace PacketReader::IP::UDP::DHCP
class DHCPopREQIP : public BaseOption //The IP to send broadcasts to
{
public:
IP_Address requestedIP{0};
IP_Address requestedIP{};
DHCPopREQIP(IP_Address data);
DHCPopREQIP(u8* data, int offset); //Offset will include Kind and Len
@ -247,7 +247,7 @@ namespace PacketReader::IP::UDP::DHCP
class DHCPopSERVIP : public BaseOption //DHCP server ip
{
public:
IP_Address serverIP{0};
IP_Address serverIP{};
DHCPopSERVIP(IP_Address data);
DHCPopSERVIP(u8* data, int offset); //Offset will include Kind and Len

View File

@ -31,11 +31,11 @@ namespace PacketReader::IP::UDP::DHCP
u32 transactionID; //xid
u16 seconds;
u16 flags;
IP_Address clientIP{0};
IP_Address yourIP{0};
IP_Address serverIP{0};
IP_Address gatewayIP{0};
u8 clientHardwareAddress[16]{0}; //always 16 bytes, regardless of HardwareAddressLength
IP_Address clientIP{};
IP_Address yourIP{};
IP_Address serverIP{};
IP_Address gatewayIP{};
u8 clientHardwareAddress[16]{}; //always 16 bytes, regardless of HardwareAddressLength
//192 bytes of padding
u32 magicCookie;
//Assumes ownership of ptrs assigned to it

View File

@ -27,7 +27,7 @@ namespace Sessions
struct ConnectionKey
{
PacketReader::IP::IP_Address ip{0};
PacketReader::IP::IP_Address ip{};
u8 protocol = 0;
u16 ps2Port = 0;
u16 srvPort = 0;

View File

@ -810,7 +810,7 @@ namespace Sessions
NetLib::ReadUInt16(payload->data, &offset, &ps2Port); //dst
}
ConnectionKey Key{0};
ConnectionKey Key{};
Key.ip = srvIP;
Key.protocol = prot;
Key.ps2Port = ps2Port;
@ -828,7 +828,7 @@ namespace Sessions
}
//Is from Fixed Port?
Key.ip = {0};
Key.ip = {};
Key.srvPort = 0;
connections->TryGetValue(Key, &s);
if (s != nullptr)

View File

@ -67,7 +67,7 @@ namespace Sessions
#endif
//Return buffers
PingResult result{0};
PingResult result{};
int icmpResponseBufferLen{0};
std::unique_ptr<u8[]> icmpResponseBuffer;

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include "common/StringUtil.h"
#include "fmt/core.h"
@ -391,7 +392,6 @@ bool TAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter,
std::vector<NET_IFINDEX> potentialBridges;
std::vector<NET_IFINDEX> searchList;
searchList.push_back(pAdapterInfo->IfIndex);
int checkCount = 1;
PMIB_IFSTACK_TABLE table;
GetIfStackTable(&table);

View File

@ -177,7 +177,7 @@ using namespace PacketReader;
using namespace PacketReader::IP;
using namespace PacketReader::IP::UDP;
const IP_Address NetAdapter::internalIP{192, 0, 2, 1};
const IP_Address NetAdapter::internalIP{{{192, 0, 2, 1}}};
const u8 NetAdapter::broadcastMAC[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
const u8 NetAdapter::internalMAC[6] = {0x76, 0x6D, 0xF4, 0x63, 0x30, 0x31};
@ -344,7 +344,7 @@ bool NetAdapter::InternalServerRecv(NetPacket* pkt)
if (ippay != nullptr)
{
IP_Packet* ippkt = new IP_Packet(ippay);
ippkt->destinationIP = {255, 255, 255, 255};
ippkt->destinationIP = {{{255, 255, 255, 255}}};
ippkt->sourceIP = internalIP;
EthernetFrame frame(ippkt);
memcpy(frame.sourceMAC, internalMAC, 6);

View File

@ -99,7 +99,7 @@ protected:
private:
//Only set if packet sent to the internal IP address
PacketReader::IP::IP_Address ps2IP{0};
PacketReader::IP::IP_Address ps2IP{};
std::thread internalRxThread;
std::atomic<bool> internalRxThreadRunning{false};
@ -133,11 +133,11 @@ protected:
void InspectSend(NetPacket* pkt);
#ifdef _WIN32
void InitInternalServer(PIP_ADAPTER_ADDRESSES adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {0}, PacketReader::IP::IP_Address subnetOverride = {0}, PacketReader::IP::IP_Address gatewayOveride = {0});
void ReloadInternalServer(PIP_ADAPTER_ADDRESSES adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {0}, PacketReader::IP::IP_Address subnetOverride = {0}, PacketReader::IP::IP_Address gatewayOveride = {0});
void InitInternalServer(PIP_ADAPTER_ADDRESSES adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {}, PacketReader::IP::IP_Address subnetOverride = {}, PacketReader::IP::IP_Address gatewayOveride = {});
void ReloadInternalServer(PIP_ADAPTER_ADDRESSES adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {}, PacketReader::IP::IP_Address subnetOverride = {}, PacketReader::IP::IP_Address gatewayOveride = {});
#elif defined(__POSIX__)
void InitInternalServer(ifaddrs* adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {0}, PacketReader::IP::IP_Address subnetOverride = {0}, PacketReader::IP::IP_Address gatewayOveride = {0});
void ReloadInternalServer(ifaddrs* adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {0}, PacketReader::IP::IP_Address subnetOverride = {0}, PacketReader::IP::IP_Address gatewayOveride = {0});
void InitInternalServer(ifaddrs* adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {}, PacketReader::IP::IP_Address subnetOverride = {}, PacketReader::IP::IP_Address gatewayOveride = {});
void ReloadInternalServer(ifaddrs* adapter, bool dhcpForceEnable = false, PacketReader::IP::IP_Address ipOverride = {}, PacketReader::IP::IP_Address subnetOverride = {}, PacketReader::IP::IP_Address gatewayOveride = {});
#endif
private:

View File

@ -186,7 +186,7 @@ SocketAdapter::SocketAdapter()
else
{
foundAdapter = AdapterUtils::GetWin32AdapterAuto(&adapter, &buffer);
adapterIP = {0};
adapterIP = {};
if (!foundAdapter)
{
@ -234,8 +234,8 @@ SocketAdapter::SocketAdapter()
//For DHCP, we need to override some settings
//DNS settings as per direct adapters
const IP_Address ps2IP{internalIP.bytes[0], internalIP.bytes[1], internalIP.bytes[2], 100};
const IP_Address subnet{255, 255, 255, 0};
const IP_Address ps2IP{{{internalIP.bytes[0], internalIP.bytes[1], internalIP.bytes[2], 100}}};
const IP_Address subnet{{{255, 255, 255, 0}}};
const IP_Address gateway = internalIP;
InitInternalServer(&adapter, true, ps2IP, subnet, gateway);
@ -450,8 +450,8 @@ void SocketAdapter::reloadSettings()
foundAdapter = AdapterUtils::GetIfAdapterAuto(&adapter, &buffer);
#endif
const IP_Address ps2IP = {internalIP.bytes[0], internalIP.bytes[1], internalIP.bytes[2], 100};
const IP_Address subnet{255, 255, 255, 0};
const IP_Address ps2IP = {{{internalIP.bytes[0], internalIP.bytes[1], internalIP.bytes[2], 100}}};
const IP_Address subnet{{{255, 255, 255, 0}}};
const IP_Address gateway = internalIP;
if (foundAdapter)
@ -477,7 +477,7 @@ bool SocketAdapter::SendIP(IP_Packet* ipPkt)
}
//Do Checksum in sub functions
ConnectionKey Key{0};
ConnectionKey Key{};
Key.ip = ipPkt->destinationIP;
Key.protocol = ipPkt->protocol;
@ -574,7 +574,7 @@ bool SocketAdapter::SendUDP(ConnectionKey Key, IP_Packet* ipPkt)
if (udp.sourcePort == udp.destinationPort || //Used for LAN games that assume the destination port
ipPkt->destinationIP == dhcpServer.broadcastIP || //Broadcast packets
ipPkt->destinationIP == IP_Address{255, 255, 255, 255} || //Limited Broadcast packets
ipPkt->destinationIP == IP_Address{{{255, 255, 255, 255}}} || //Limited Broadcast packets
(ipPkt->destinationIP.bytes[0] & 0xF0) == 0xE0) //Multicast address start with 0b1110
{
UDP_FixedPort* fPort = nullptr;
@ -586,7 +586,7 @@ bool SocketAdapter::SendUDP(ConnectionKey Key, IP_Packet* ipPkt)
}
else
{
ConnectionKey fKey{0};
ConnectionKey fKey{};
fKey.protocol = (u8)IP_Type::UDP;
fKey.ps2Port = udp.sourcePort;
fKey.srvPort = 0;
@ -596,7 +596,7 @@ bool SocketAdapter::SendUDP(ConnectionKey Key, IP_Packet* ipPkt)
fPort = new UDP_FixedPort(fKey, adapterIP, udp.sourcePort);
fPort->AddConnectionClosedHandler([&](BaseSession* session) { HandleFixedPortClosed(session); });
fPort->destIP = {0, 0, 0, 0};
fPort->destIP = {};
fPort->sourceIP = dhcpServer.ps2IP;
connections.Add(fKey, fPort);
@ -605,7 +605,7 @@ bool SocketAdapter::SendUDP(ConnectionKey Key, IP_Packet* ipPkt)
Console.WriteLn("DEV9: Socket: Creating New UDP Connection from FixedPort %d", udp.destinationPort);
s = fPort->NewClientSession(Key,
ipPkt->destinationIP == dhcpServer.broadcastIP || ipPkt->destinationIP == IP_Address{255, 255, 255, 255},
ipPkt->destinationIP == dhcpServer.broadcastIP || ipPkt->destinationIP == IP_Address{{{255, 255, 255, 255}}},
(ipPkt->destinationIP.bytes[0] & 0xF0) == 0xE0);
}
else