diff --git a/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp b/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp index 3384daff39e76..cec51daa0b2ce 100644 --- a/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp +++ b/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp @@ -91,8 +91,8 @@ namespace Sessions return; } - icmpEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (icmpEvent == NULL) + icmpEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); + if (icmpEvent == nullptr) { Console.Error("DEV9: ICMP: Failed to Create Event"); IcmpCloseHandle(icmpFile); diff --git a/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_In.cpp b/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_In.cpp index 241edb4d6bbc2..fe442fdeb64b6 100644 --- a/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_In.cpp +++ b/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_In.cpp @@ -169,7 +169,7 @@ namespace Sessions memcpy(recivedData->data.get(), buffer.get(), recived); std::unique_ptr iRet = CreateBasePacket(recivedData); - IncrementMyNumber((u32)recived); + IncrementMyNumber(static_cast(recived)); iRet->SetACK(true); iRet->SetPSH(true); diff --git a/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_Out.cpp b/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_Out.cpp index b84faa33d2f83..8cb640cbab50e 100644 --- a/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_Out.cpp +++ b/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_Out.cpp @@ -193,7 +193,7 @@ namespace Sessions #endif - const int noDelay = true; // BOOL on Windows + constexpr int noDelay = true; // BOOL on Windows ret = setsockopt(client, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&noDelay), sizeof(noDelay)); if (ret != 0) diff --git a/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp b/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp index 77f03af574231..160612a0fc247 100644 --- a/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp +++ b/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp @@ -65,7 +65,7 @@ namespace Sessions return; } - const int reuseAddress = true; // BOOL on Windows + constexpr int reuseAddress = true; // BOOL on Windows ret = setsockopt(client, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&reuseAddress), sizeof(reuseAddress)); if (ret == SOCKET_ERROR) @@ -76,7 +76,7 @@ namespace Sessions errno); #endif - const int broadcastEnable = true; // BOOL on Windows + constexpr int broadcastEnable = true; // BOOL on Windows ret = setsockopt(client, SOL_SOCKET, SO_BROADCAST, reinterpret_cast(&broadcastEnable), sizeof(broadcastEnable)); if (ret == SOCKET_ERROR) diff --git a/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp b/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp index 7e9baeecc2ddd..f1e60d09224d3 100644 --- a/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp +++ b/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp @@ -225,7 +225,7 @@ namespace Sessions return false; } - const int reuseAddress = true; // BOOL on Windows + constexpr int reuseAddress = true; // BOOL on Windows ret = setsockopt(client, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&reuseAddress), sizeof(reuseAddress)); if (ret == SOCKET_ERROR) diff --git a/pcsx2/DEV9/flash.cpp b/pcsx2/DEV9/flash.cpp index 7c8500b7194b9..7c92f73b6c31d 100644 --- a/pcsx2/DEV9/flash.cpp +++ b/pcsx2/DEV9/flash.cpp @@ -16,7 +16,7 @@ #define CARD_SIZE_ECC (1024 * BLOCK_SIZE_ECC) -static u32 ctrl, cmd = (u32)-1, address, id, counter, addrbyte; +static u32 ctrl, cmd = static_cast(-1), address, id, counter, addrbyte; static u8 data[PAGE_SIZE_ECC], file[CARD_SIZE_ECC]; static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char blah[4]); diff --git a/pcsx2/DEV9/net.cpp b/pcsx2/DEV9/net.cpp index a6a6fc3cdab64..6fc752ae84f6a 100644 --- a/pcsx2/DEV9/net.cpp +++ b/pcsx2/DEV9/net.cpp @@ -208,12 +208,12 @@ void NetAdapter::InspectSend(NetPacket* pkt) if (EmuConfig.DEV9.EthLogDNS || EmuConfig.DEV9.EthLogDHCP) { EthernetFrame frame(pkt); - if (frame.protocol == (u16)EtherType::IPv4) + if (frame.protocol == static_cast(EtherType::IPv4)) { PayloadPtr* payload = static_cast(frame.GetPayload()); IP_Packet ippkt(payload->data, payload->GetLength()); - if (ippkt.protocol == (u16)IP_Type::UDP) + if (ippkt.protocol == static_cast(IP_Type::UDP)) { IP_PayloadPtr* ipPayload = static_cast(ippkt.GetPayload()); UDP_Packet udppkt(ipPayload->data, ipPayload->GetLength()); @@ -240,12 +240,12 @@ void NetAdapter::InspectRecv(NetPacket* pkt) if (EmuConfig.DEV9.EthLogDNS || EmuConfig.DEV9.EthLogDHCP) { EthernetFrame frame(pkt); - if (frame.protocol == (u16)EtherType::IPv4) + if (frame.protocol == static_cast(EtherType::IPv4)) { PayloadPtr* payload = static_cast(frame.GetPayload()); IP_Packet ippkt(payload->data, payload->GetLength()); - if (ippkt.protocol == (u16)IP_Type::UDP) + if (ippkt.protocol == static_cast(IP_Type::UDP)) { IP_PayloadPtr* ipPayload = static_cast(ippkt.GetPayload()); UDP_Packet udppkt(ipPayload->data, ipPayload->GetLength()); @@ -350,7 +350,7 @@ bool NetAdapter::InternalServerRecv(NetPacket* pkt) EthernetFrame frame(ippkt); frame.sourceMAC = internalMAC; frame.destinationMAC = ps2MAC; - frame.protocol = (u16)EtherType::IPv4; + frame.protocol = static_cast(EtherType::IPv4); frame.WritePacket(pkt); InspectRecv(pkt); return true; @@ -365,7 +365,7 @@ bool NetAdapter::InternalServerRecv(NetPacket* pkt) EthernetFrame frame(ippkt); frame.sourceMAC = internalMAC; frame.destinationMAC = ps2MAC; - frame.protocol = (u16)EtherType::IPv4; + frame.protocol = static_cast(EtherType::IPv4); frame.WritePacket(pkt); InspectRecv(pkt); return true; @@ -377,12 +377,12 @@ bool NetAdapter::InternalServerRecv(NetPacket* pkt) bool NetAdapter::InternalServerSend(NetPacket* pkt) { EthernetFrame frame(pkt); - if (frame.protocol == (u16)EtherType::IPv4) + if (frame.protocol == static_cast(EtherType::IPv4)) { PayloadPtr* payload = static_cast(frame.GetPayload()); IP_Packet ippkt(payload->data, payload->GetLength()); - if (ippkt.protocol == (u16)IP_Type::UDP) + if (ippkt.protocol == static_cast(IP_Type::UDP)) { IP_PayloadPtr* ipPayload = static_cast(ippkt.GetPayload()); UDP_Packet udppkt(ipPayload->data, ipPayload->GetLength()); @@ -397,7 +397,7 @@ bool NetAdapter::InternalServerSend(NetPacket* pkt) if (ippkt.destinationIP == internalIP) { - if (ippkt.protocol == (u16)IP_Type::UDP) + if (ippkt.protocol == static_cast(IP_Type::UDP)) { ps2IP = ippkt.sourceIP; diff --git a/pcsx2/DEV9/net.h b/pcsx2/DEV9/net.h index 7d77807796226..a8b0c18320aa9 100644 --- a/pcsx2/DEV9/net.h +++ b/pcsx2/DEV9/net.h @@ -70,11 +70,11 @@ enum struct AdapterOptions : int constexpr enum AdapterOptions operator|(const enum AdapterOptions selfValue, const enum AdapterOptions inValue) { - return (enum AdapterOptions)(int(selfValue) | int(inValue)); + return static_cast(static_cast(selfValue) | static_cast(inValue)); } constexpr enum AdapterOptions operator&(const enum AdapterOptions selfValue, const enum AdapterOptions inValue) { - return (enum AdapterOptions)(int(selfValue) & int(inValue)); + return static_cast(static_cast(selfValue) & static_cast(inValue)); } class NetAdapter diff --git a/pcsx2/DEV9/pcap_io.cpp b/pcsx2/DEV9/pcap_io.cpp index 519b08e46c377..62fa8c12873bb 100644 --- a/pcsx2/DEV9/pcap_io.cpp +++ b/pcsx2/DEV9/pcap_io.cpp @@ -136,7 +136,7 @@ bool PCAPAdapter::recv(NetPacket* pkt) pxAssert(header->len == header->caplen); memcpy(pkt->buffer, pkt_data, header->len); - pkt->size = (int)header->len; + pkt->size = static_cast(header->len); if (!switched) SetMACBridgedRecv(pkt); @@ -339,7 +339,7 @@ bool PCAPAdapter::SetMACSwitchedFilter(MAC_Address mac) void PCAPAdapter::SetMACBridgedRecv(NetPacket* pkt) { EthernetFrameEditor frame(pkt); - if (frame.GetProtocol() == (u16)EtherType::IPv4) // IP + if (frame.GetProtocol() == static_cast(EtherType::IPv4)) // IP { // Compare DEST IP in IP with the PS2's IP, if they match, change DEST MAC to ps2MAC. PayloadPtr* payload = frame.GetPayload(); @@ -347,7 +347,7 @@ void PCAPAdapter::SetMACBridgedRecv(NetPacket* pkt) if (ippkt.destinationIP == ps2IP) frame.SetDestinationMAC(ps2MAC); } - if (frame.GetProtocol() == (u16)EtherType::ARP) // ARP + if (frame.GetProtocol() == static_cast(EtherType::ARP)) // ARP { // Compare DEST IP in ARP with the PS2's IP, if they match, DEST MAC to ps2MAC on both ARP and ETH Packet headers. ARP_PacketEditor arpPkt(frame.GetPayload()); @@ -362,13 +362,13 @@ void PCAPAdapter::SetMACBridgedRecv(NetPacket* pkt) void PCAPAdapter::SetMACBridgedSend(NetPacket* pkt) { EthernetFrameEditor frame(pkt); - if (frame.GetProtocol() == (u16)EtherType::IPv4) // IP + if (frame.GetProtocol() == static_cast(EtherType::IPv4)) // IP { PayloadPtr* payload = frame.GetPayload(); IP_Packet ippkt(payload->data, payload->GetLength()); ps2IP = ippkt.sourceIP; } - if (frame.GetProtocol() == (u16)EtherType::ARP) // ARP + if (frame.GetProtocol() == static_cast(EtherType::ARP)) // ARP { ARP_PacketEditor arpPkt(frame.GetPayload()); ps2IP = *(IP_Address*)arpPkt.SenderProtocolAddress(); diff --git a/pcsx2/DEV9/pcap_io.h b/pcsx2/DEV9/pcap_io.h index 85c2fdce3553e..a81d9182b5654 100644 --- a/pcsx2/DEV9/pcap_io.h +++ b/pcsx2/DEV9/pcap_io.h @@ -37,7 +37,6 @@ class PCAPAdapter : public NetAdapter private: bool InitPCAP(const std::string& adapter, bool promiscuous); - void InitPCAPDumper(); bool SetMACSwitchedFilter(PacketReader::MAC_Address mac); void SetMACBridgedRecv(NetPacket* pkt); diff --git a/pcsx2/DEV9/smap.cpp b/pcsx2/DEV9/smap.cpp index b77d7d81d59a8..6ce5d976a0152 100644 --- a/pcsx2/DEV9/smap.cpp +++ b/pcsx2/DEV9/smap.cpp @@ -302,16 +302,14 @@ void emac3_write(u32 addr) value |= SMAP_E3_PHY_OP_COMP; int reg = value & (SMAP_E3_PHY_REG_ADDR_MSK); u16 val = value >> 16; - switch (reg) + if (reg == SMAP_DsPHYTER_BMCR) { - case SMAP_DsPHYTER_BMCR: - if (val & SMAP_PHY_BMCR_RST) - { - ad_reset(); - } - val &= ~SMAP_PHY_BMCR_RST; - val |= 0x1; - break; + if (val & SMAP_PHY_BMCR_RST) + { + ad_reset(); + } + val &= ~SMAP_PHY_BMCR_RST; + val |= 0x1; } //DevCon.WriteLn("DEV9: phy_write %d: %x", reg, val); dev9.phyregs[reg] = val; diff --git a/pcsx2/DEV9/sockets.cpp b/pcsx2/DEV9/sockets.cpp index 01ad6946dae60..6061c845a140a 100644 --- a/pcsx2/DEV9/sockets.cpp +++ b/pcsx2/DEV9/sockets.cpp @@ -268,24 +268,24 @@ bool SocketAdapter::send(NetPacket* pkt) switch (frame.protocol) { - case (u16)EtherType::null: + case static_cast(EtherType::null): case 0x0C00: //Packets with the above ethertypes get sent when the adapter is reset //Catch them here instead of printing an error return true; - case (int)EtherType::IPv4: + case static_cast(EtherType::IPv4): { PayloadPtr* payload = static_cast(frame.GetPayload()); IP_Packet ippkt(payload->data, payload->GetLength()); return SendIP(&ippkt); } - case (u16)EtherType::ARP: + case static_cast(EtherType::ARP): { PayloadPtr* payload = static_cast(frame.GetPayload()); ARP_Packet arpPkt(payload->data, payload->GetLength()); - if (arpPkt.protocol == (u16)EtherType::IPv4) + if (arpPkt.protocol == static_cast(EtherType::IPv4)) { if (arpPkt.op == 1) //ARP request { @@ -304,7 +304,7 @@ bool SocketAdapter::send(NetPacket* pkt) EthernetFrame* retARP = new EthernetFrame(arpRet); retARP->destinationMAC = ps2MAC; retARP->sourceMAC = internalMAC; - retARP->protocol = (u16)EtherType::ARP; + retARP->protocol = static_cast(EtherType::ARP); vRecBuffer.Enqueue(retARP); } @@ -567,7 +567,7 @@ void SocketAdapter::HandleConnectionClosed(BaseSession* sender) void SocketAdapter::HandleFixedPortClosed(BaseSession* sender) { - ConnectionKey key = sender->key; + const ConnectionKey key = sender->key; connections.Remove(key); fixedUDPPorts.Remove(key.ps2Port);