Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 23, 2024
2 parents 0e93139 + e3fedf1 commit 9098e64
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 42 deletions.
4 changes: 2 additions & 2 deletions pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_In.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace Sessions
memcpy(recivedData->data.get(), buffer.get(), recived);

std::unique_ptr<TCP_Packet> iRet = CreateBasePacket(recivedData);
IncrementMyNumber((u32)recived);
IncrementMyNumber(static_cast<u32>(recived));

iRet->SetACK(true);
iRet->SetPSH(true);
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/DEV9/Sessions/TCP_Session/TCP_Session_Out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(&noDelay), sizeof(noDelay));

if (ret != 0)
Expand Down
4 changes: 2 additions & 2 deletions pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(&reuseAddress), sizeof(reuseAddress));

if (ret == SOCKET_ERROR)
Expand All @@ -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<const char*>(&broadcastEnable), sizeof(broadcastEnable));

if (ret == SOCKET_ERROR)
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(&reuseAddress), sizeof(reuseAddress));

if (ret == SOCKET_ERROR)
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/DEV9/flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>(-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]);
Expand Down
18 changes: 9 additions & 9 deletions pcsx2/DEV9/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u16>(EtherType::IPv4))
{
PayloadPtr* payload = static_cast<PayloadPtr*>(frame.GetPayload());
IP_Packet ippkt(payload->data, payload->GetLength());

if (ippkt.protocol == (u16)IP_Type::UDP)
if (ippkt.protocol == static_cast<u16>(IP_Type::UDP))
{
IP_PayloadPtr* ipPayload = static_cast<IP_PayloadPtr*>(ippkt.GetPayload());
UDP_Packet udppkt(ipPayload->data, ipPayload->GetLength());
Expand All @@ -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<u16>(EtherType::IPv4))
{
PayloadPtr* payload = static_cast<PayloadPtr*>(frame.GetPayload());
IP_Packet ippkt(payload->data, payload->GetLength());

if (ippkt.protocol == (u16)IP_Type::UDP)
if (ippkt.protocol == static_cast<u16>(IP_Type::UDP))
{
IP_PayloadPtr* ipPayload = static_cast<IP_PayloadPtr*>(ippkt.GetPayload());
UDP_Packet udppkt(ipPayload->data, ipPayload->GetLength());
Expand Down Expand Up @@ -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<u16>(EtherType::IPv4);
frame.WritePacket(pkt);
InspectRecv(pkt);
return true;
Expand All @@ -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<u16>(EtherType::IPv4);
frame.WritePacket(pkt);
InspectRecv(pkt);
return true;
Expand All @@ -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<u16>(EtherType::IPv4))
{
PayloadPtr* payload = static_cast<PayloadPtr*>(frame.GetPayload());
IP_Packet ippkt(payload->data, payload->GetLength());

if (ippkt.protocol == (u16)IP_Type::UDP)
if (ippkt.protocol == static_cast<u16>(IP_Type::UDP))
{
IP_PayloadPtr* ipPayload = static_cast<IP_PayloadPtr*>(ippkt.GetPayload());
UDP_Packet udppkt(ipPayload->data, ipPayload->GetLength());
Expand All @@ -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<u16>(IP_Type::UDP))
{
ps2IP = ippkt.sourceIP;

Expand Down
4 changes: 2 additions & 2 deletions pcsx2/DEV9/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<enum AdapterOptions>(static_cast<int>(selfValue) | static_cast<int>(inValue));
}
constexpr enum AdapterOptions operator&(const enum AdapterOptions selfValue, const enum AdapterOptions inValue)
{
return (enum AdapterOptions)(int(selfValue) & int(inValue));
return static_cast<enum AdapterOptions>(static_cast<int>(selfValue) & static_cast<int>(inValue));
}

class NetAdapter
Expand Down
10 changes: 5 additions & 5 deletions pcsx2/DEV9/pcap_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(header->len);

if (!switched)
SetMACBridgedRecv(pkt);
Expand Down Expand Up @@ -339,15 +339,15 @@ 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<u16>(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();
IP_Packet ippkt(payload->data, payload->GetLength());
if (ippkt.destinationIP == ps2IP)
frame.SetDestinationMAC(ps2MAC);
}
if (frame.GetProtocol() == (u16)EtherType::ARP) // ARP
if (frame.GetProtocol() == static_cast<u16>(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());
Expand All @@ -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<u16>(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<u16>(EtherType::ARP)) // ARP
{
ARP_PacketEditor arpPkt(frame.GetPayload());
ps2IP = *(IP_Address*)arpPkt.SenderProtocolAddress();
Expand Down
1 change: 0 additions & 1 deletion pcsx2/DEV9/pcap_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 7 additions & 9 deletions pcsx2/DEV9/smap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions pcsx2/DEV9/sockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,24 +268,24 @@ bool SocketAdapter::send(NetPacket* pkt)

switch (frame.protocol)
{
case (u16)EtherType::null:
case static_cast<u16>(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<int>(EtherType::IPv4):
{
PayloadPtr* payload = static_cast<PayloadPtr*>(frame.GetPayload());
IP_Packet ippkt(payload->data, payload->GetLength());

return SendIP(&ippkt);
}
case (u16)EtherType::ARP:
case static_cast<u16>(EtherType::ARP):
{
PayloadPtr* payload = static_cast<PayloadPtr*>(frame.GetPayload());
ARP_Packet arpPkt(payload->data, payload->GetLength());

if (arpPkt.protocol == (u16)EtherType::IPv4)
if (arpPkt.protocol == static_cast<u16>(EtherType::IPv4))
{
if (arpPkt.op == 1) //ARP request
{
Expand All @@ -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<u16>(EtherType::ARP);

vRecBuffer.Enqueue(retARP);
}
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion pcsx2/GameList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
}

const std::string_view filename = Path::GetFileName(ffd.FileName);
progress->SetFormattedStatusText(fmt::format(TRANSLATE_FS("GameList","Scanning {}..."), filename.data()).c_str());
progress->SetStatusText(fmt::format(TRANSLATE_FS("GameList","Scanning {}..."), filename.data()).c_str());
ScanFile(std::move(ffd.FileName), ffd.ModificationTime, lock, played_time_map, custom_attributes_ini);
progress->SetProgressValue(files_scanned);
}
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/PINE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ bool PINEServer::Initialize(int slot)
return false;
}
server.sun_family = AF_UNIX;
strcpy(server.sun_path, m_socket_name.c_str());
StringUtil::Strlcpy(server.sun_path, m_socket_name, sizeof(server.sun_path));

// we unlink the socket so that when releasing this thread the socket gets
// freed even if we didn't close correctly the loop
Expand Down

0 comments on commit 9098e64

Please sign in to comment.