From 37da945609055ab76718ea3bad106f2364a402b9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 18 Jul 2016 01:12:52 -0400 Subject: [PATCH 1/4] EXI_DeviceEthernet: Correct constness of function parameters --- Source/Core/Core/HW/BBA-TAP/TAP_Apple.cpp | 2 +- Source/Core/Core/HW/BBA-TAP/TAP_Unix.cpp | 2 +- Source/Core/Core/HW/BBA-TAP/TAP_Win32.cpp | 2 +- Source/Core/Core/HW/EXI_DeviceEthernet.cpp | 4 ++-- Source/Core/Core/HW/EXI_DeviceEthernet.h | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/HW/BBA-TAP/TAP_Apple.cpp b/Source/Core/Core/HW/BBA-TAP/TAP_Apple.cpp index 5681f0b507..6246c21bf3 100644 --- a/Source/Core/Core/HW/BBA-TAP/TAP_Apple.cpp +++ b/Source/Core/Core/HW/BBA-TAP/TAP_Apple.cpp @@ -43,7 +43,7 @@ bool CEXIETHERNET::IsActivated() return fd != -1; } -bool CEXIETHERNET::SendFrame(u8* frame, u32 size) +bool CEXIETHERNET::SendFrame(const u8* frame, u32 size) { INFO_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(frame, size, 0x10).c_str()); diff --git a/Source/Core/Core/HW/BBA-TAP/TAP_Unix.cpp b/Source/Core/Core/HW/BBA-TAP/TAP_Unix.cpp index ad2f67cda0..0108706856 100644 --- a/Source/Core/Core/HW/BBA-TAP/TAP_Unix.cpp +++ b/Source/Core/Core/HW/BBA-TAP/TAP_Unix.cpp @@ -100,7 +100,7 @@ bool CEXIETHERNET::IsActivated() #endif } -bool CEXIETHERNET::SendFrame(u8* frame, u32 size) +bool CEXIETHERNET::SendFrame(const u8* frame, u32 size) { #ifdef __linux__ INFO_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(frame, size, 0x10).c_str()); diff --git a/Source/Core/Core/HW/BBA-TAP/TAP_Win32.cpp b/Source/Core/Core/HW/BBA-TAP/TAP_Win32.cpp index a3e16047ab..c817d370e6 100644 --- a/Source/Core/Core/HW/BBA-TAP/TAP_Win32.cpp +++ b/Source/Core/Core/HW/BBA-TAP/TAP_Win32.cpp @@ -307,7 +307,7 @@ static void ReadThreadHandler(CEXIETHERNET* self) } } -bool CEXIETHERNET::SendFrame(u8* frame, u32 size) +bool CEXIETHERNET::SendFrame(const u8* frame, u32 size) { DEBUG_LOG(SP1, "SendFrame %u bytes:\n%s", size, ArrayToString(frame, size, 0x10).c_str()); diff --git a/Source/Core/Core/HW/EXI_DeviceEthernet.cpp b/Source/Core/Core/HW/EXI_DeviceEthernet.cpp index dd0aed4be9..42352c7d98 100644 --- a/Source/Core/Core/HW/EXI_DeviceEthernet.cpp +++ b/Source/Core/Core/HW/EXI_DeviceEthernet.cpp @@ -370,7 +370,7 @@ void CEXIETHERNET::MXCommandHandler(u32 data, u32 size) } } -void CEXIETHERNET::DirectFIFOWrite(u8* data, u32 size) +void CEXIETHERNET::DirectFIFOWrite(const u8* data, u32 size) { // In direct mode, the hardware handles creating the state required by the // GMAC instead of finagling with packet descriptors and such @@ -412,7 +412,7 @@ void CEXIETHERNET::SendComplete() mBbaMem[BBA_LTPS] = 0; } -inline u8 CEXIETHERNET::HashIndex(u8* dest_eth_addr) +inline u8 CEXIETHERNET::HashIndex(const u8* dest_eth_addr) { // Calculate CRC u32 crc = 0xffffffff; diff --git a/Source/Core/Core/HW/EXI_DeviceEthernet.h b/Source/Core/Core/HW/EXI_DeviceEthernet.h index 26f0e8e28d..c73d1c9df7 100644 --- a/Source/Core/Core/HW/EXI_DeviceEthernet.h +++ b/Source/Core/Core/HW/EXI_DeviceEthernet.h @@ -297,11 +297,11 @@ public: const char* GetRegisterName() const; void MXHardReset(); void MXCommandHandler(u32 data, u32 size); - void DirectFIFOWrite(u8* data, u32 size); + void DirectFIFOWrite(const u8* data, u32 size); void SendFromDirectFIFO(); void SendFromPacketBuffer(); void SendComplete(); - u8 HashIndex(u8* dest_eth_addr); + u8 HashIndex(const u8* dest_eth_addr); bool RecvMACFilter(); void inc_rwp(); bool RecvHandlePacket(); @@ -313,7 +313,7 @@ public: bool Activate(); void Deactivate(); bool IsActivated(); - bool SendFrame(u8* frame, u32 size); + bool SendFrame(const u8* frame, u32 size); bool RecvInit(); void RecvStart(); void RecvStop(); From 6eaa1aab5c32d2fcbc9d149b793dd7a10c9ebf50 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 18 Jul 2016 01:41:45 -0400 Subject: [PATCH 2/4] EXI_DeviceAGP: Correct constness for CRC8 parameter --- Source/Core/Core/HW/EXI_DeviceAGP.cpp | 2 +- Source/Core/Core/HW/EXI_DeviceAGP.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/EXI_DeviceAGP.cpp b/Source/Core/Core/HW/EXI_DeviceAGP.cpp index 44bae38db1..397ffd3979 100644 --- a/Source/Core/Core/HW/EXI_DeviceAGP.cpp +++ b/Source/Core/Core/HW/EXI_DeviceAGP.cpp @@ -38,7 +38,7 @@ CEXIAgp::~CEXIAgp() SaveFileFromEEPROM(gbapath + ".sav"); } -void CEXIAgp::CRC8(u8* data, u32 size) +void CEXIAgp::CRC8(const u8* data, u32 size) { for (u32 it = 0; it < size; it++) { diff --git a/Source/Core/Core/HW/EXI_DeviceAGP.h b/Source/Core/Core/HW/EXI_DeviceAGP.h index 49fc697572..4a97a17eef 100644 --- a/Source/Core/Core/HW/EXI_DeviceAGP.h +++ b/Source/Core/Core/HW/EXI_DeviceAGP.h @@ -57,7 +57,7 @@ private: void LoadFileToEEPROM(const std::string& filename); void SaveFileFromEEPROM(const std::string& filename); void LoadRom(); - void CRC8(u8* data, u32 size); + void CRC8(const u8* data, u32 size); u8 m_hash = 0; u32 m_current_cmd = 0; From 5161351ca3eafa8026e93a23b82b893b472da33c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 18 Jul 2016 01:47:03 -0400 Subject: [PATCH 3/4] EXI_DeviceMic: Don't cast away const in Pa_Callback --- Source/Core/Core/HW/EXI_DeviceMic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/EXI_DeviceMic.cpp b/Source/Core/Core/HW/EXI_DeviceMic.cpp index 4115fe6497..27d8ec1d17 100644 --- a/Source/Core/Core/HW/EXI_DeviceMic.cpp +++ b/Source/Core/Core/HW/EXI_DeviceMic.cpp @@ -59,7 +59,7 @@ static int Pa_Callback(const void* inputBuffer, void* outputBuffer, unsigned lon if (mic->stream_wpos + mic->buff_size_samples > mic->stream_size) mic->stream_wpos = 0; - s16* buff_in = (s16*)inputBuffer; + const s16* buff_in = static_cast(inputBuffer); s16* buff_out = &mic->stream_buffer[mic->stream_wpos]; if (buff_in == nullptr) From 902a0ccedf3be9a04e2ba95f261ef50f9ba603c4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 18 Jul 2016 02:15:07 -0400 Subject: [PATCH 4/4] Sram: Correct constness of SetCardFlashID parameter --- Source/Core/Core/HW/Sram.cpp | 4 ++-- Source/Core/Core/HW/Sram.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/HW/Sram.cpp b/Source/Core/Core/HW/Sram.cpp index 4c8884c43d..47b5f7ca08 100644 --- a/Source/Core/Core/HW/Sram.cpp +++ b/Source/Core/Core/HW/Sram.cpp @@ -58,9 +58,9 @@ void InitSRAM() } } -void SetCardFlashID(u8* buffer, u8 card_index) +void SetCardFlashID(const u8* buffer, u8 card_index) { - u64 rand = Common::swap64(*(u64*)&(buffer[12])); + u64 rand = Common::swap64(&buffer[12]); u8 csum = 0; for (int i = 0; i < 12; i++) { diff --git a/Source/Core/Core/HW/Sram.h b/Source/Core/Core/HW/Sram.h index eb7be1e8ae..0f5db4ea10 100644 --- a/Source/Core/Core/HW/Sram.h +++ b/Source/Core/Core/HW/Sram.h @@ -79,7 +79,7 @@ union SRAM { }; #pragma pack(pop) void InitSRAM(); -void SetCardFlashID(u8* buffer, u8 card_index); +void SetCardFlashID(const u8* buffer, u8 card_index); void FixSRAMChecksums(); extern SRAM sram_dump;