From 59dc7cfe7dc962ef5cddbb0055fee6923db33445 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 8 Apr 2020 18:19:37 -0700 Subject: [PATCH] Use size_t in some DSP code code --- Source/Core/Common/Hash.cpp | 2 +- Source/Core/Common/Hash.h | 2 +- Source/Core/Core/DSP/DSPCodeUtil.cpp | 8 ++++---- Source/Core/Core/DSP/DSPCodeUtil.h | 2 +- Source/Core/Core/DSP/DSPHost.h | 2 +- Source/Core/Core/HW/DSPLLE/DSPHost.cpp | 2 +- Source/DSPTool/DSPTool.cpp | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp index 525f0b21e2..395865c475 100644 --- a/Source/Core/Common/Hash.cpp +++ b/Source/Core/Common/Hash.cpp @@ -95,7 +95,7 @@ u32 HashAdler32(const u8* data, size_t len) // Stupid hash - but can't go back now :) // Don't use for new things. At least it's reasonably fast. -u32 HashEctor(const u8* ptr, int length) +u32 HashEctor(const u8* ptr, size_t length) { u32 crc = 0; diff --git a/Source/Core/Common/Hash.h b/Source/Core/Common/Hash.h index 488f68cc1a..9d1af1847c 100644 --- a/Source/Core/Common/Hash.h +++ b/Source/Core/Common/Hash.h @@ -12,7 +12,7 @@ namespace Common { u32 HashFletcher(const u8* data_u8, size_t length); // FAST. Length & 1 == 0. u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightly slower -u32 HashEctor(const u8* ptr, int length); // JUNK. DO NOT USE FOR NEW THINGS +u32 HashEctor(const u8* ptr, size_t length); // JUNK. DO NOT USE FOR NEW THINGS u64 GetHash64(const u8* src, u32 len, u32 samples); void SetHash64Function(); } // namespace Common diff --git a/Source/Core/Core/DSP/DSPCodeUtil.cpp b/Source/Core/Core/DSP/DSPCodeUtil.cpp index 313bda78ab..ee0428151f 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.cpp +++ b/Source/Core/Core/DSP/DSPCodeUtil.cpp @@ -68,11 +68,11 @@ bool Compare(const std::vector& code1, const std::vector& code2) if (code1.size() != code2.size()) printf("Size difference! 1=%zu 2=%zu\n", code1.size(), code2.size()); u32 count_equal = 0; - const int min_size = std::min((int)code1.size(), (int)code2.size()); + const u16 min_size = static_cast(std::min(code1.size(), code2.size())); AssemblerSettings settings; DSPDisassembler disassembler(settings); - for (int i = 0; i < min_size; i++) + for (u16 i = 0; i < min_size; i++) { if (code1[i] == code2[i]) { @@ -93,7 +93,7 @@ bool Compare(const std::vector& code1, const std::vector& code2) { printf("Extra code words:\n"); const std::vector& longest = code1.size() > code2.size() ? code1 : code2; - for (int i = min_size; i < (int)longest.size(); i++) + for (u16 i = min_size; i < longest.size(); i++) { u16 pc = i; std::string line; @@ -146,7 +146,7 @@ bool SaveBinary(const std::vector& code, const std::string& filename) return File::WriteStringToFile(filename, buffer); } -bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc) +bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc) { const std::string root_name = File::GetUserPath(D_DUMPDSP_IDX) + fmt::format("DSP_UC_{:08X}", crc); diff --git a/Source/Core/Core/DSP/DSPCodeUtil.h b/Source/Core/Core/DSP/DSPCodeUtil.h index 3d20ffa9cf..d7314153cd 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.h +++ b/Source/Core/Core/DSP/DSPCodeUtil.h @@ -24,5 +24,5 @@ std::vector BinaryStringBEToCode(const std::string& str); std::optional> LoadBinary(const std::string& filename); bool SaveBinary(const std::vector& code, const std::string& filename); -bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc); +bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc); } // namespace DSP diff --git a/Source/Core/Core/DSP/DSPHost.h b/Source/Core/Core/DSP/DSPHost.h index d771fd9b48..f5dd42f0e4 100644 --- a/Source/Core/Core/DSP/DSPHost.h +++ b/Source/Core/Core/DSP/DSPHost.h @@ -21,6 +21,6 @@ void OSD_AddMessage(std::string str, u32 ms); bool OnThread(); bool IsWiiHost(); void InterruptRequest(); -void CodeLoaded(const u8* ptr, int size); +void CodeLoaded(const u8* ptr, size_t size); void UpdateDebugger(); } // namespace DSP::Host diff --git a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp index ab88e457d2..8ac63b5876 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp @@ -57,7 +57,7 @@ void InterruptRequest() DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); } -void CodeLoaded(const u8* ptr, int size) +void CodeLoaded(const u8* ptr, size_t size) { if (SConfig::GetInstance().m_DumpUCode) { diff --git a/Source/DSPTool/DSPTool.cpp b/Source/DSPTool/DSPTool.cpp index bd3335189d..574d41e0b9 100644 --- a/Source/DSPTool/DSPTool.cpp +++ b/Source/DSPTool/DSPTool.cpp @@ -33,7 +33,7 @@ bool DSP::Host::IsWiiHost() { return false; } -void DSP::Host::CodeLoaded(const u8* ptr, int size) +void DSP::Host::CodeLoaded(const u8* ptr, size_t size) { } void DSP::Host::InterruptRequest()