diff options
| author | Sepalani <sepalani@hotmail.fr> | 2020-03-09 13:27:03 +0400 |
|---|---|---|
| committer | Sepalani <sepalani@hotmail.fr> | 2020-03-16 23:48:03 +0400 |
| commit | e06bdaf42696038d7beed277be68a7996cff4e37 (patch) | |
| tree | ac869ecc233647e41ce0c2a1fa11152b3066ec1d /Source | |
| parent | 25d5f0d9efd2af58b5389a358794ff10359e0164 (diff) | |
AddressSpace: Fix constness
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/HW/AddressSpace.cpp | 19 | ||||
| -rw-r--r-- | Source/Core/Core/HW/AddressSpace.h | 4 |
2 files changed, 12 insertions, 11 deletions
diff --git a/Source/Core/Core/HW/AddressSpace.cpp b/Source/Core/Core/HW/AddressSpace.cpp index 3a98414c30..c84f62a7ef 100644 --- a/Source/Core/Core/HW/AddressSpace.cpp +++ b/Source/Core/Core/HW/AddressSpace.cpp @@ -68,8 +68,8 @@ Accessors::iterator Accessors::end() const return nullptr; } -std::optional<u32> Accessors::Search(u32 haystack_start, u8* needle_start, u32 needle_size, - bool forwards) const +std::optional<u32> Accessors::Search(u32 haystack_start, const u8* needle_start, + std::size_t needle_size, bool forwards) const { return std::nullopt; } @@ -91,7 +91,7 @@ struct EffectiveAddressSpaceAccessors : Accessors void WriteU64(u32 address, u64 value) override { PowerPC::HostWrite_U64(value, address); } float ReadF32(u32 address) const override { return PowerPC::HostRead_F32(address); }; - bool Matches(u32 haystack_start, u8* needle_start, u32 needle_size) const + bool Matches(u32 haystack_start, const u8* needle_start, std::size_t needle_size) const { u32 page_base = haystack_start & 0xfffff000; u32 offset = haystack_start & 0x0000fff; @@ -121,7 +121,7 @@ struct EffectiveAddressSpaceAccessors : Accessors return false; } - u32 chunk_size = std::min(0x1000 - offset, needle_size); + std::size_t chunk_size = std::min<std::size_t>(0x1000 - offset, needle_size); if (memcmp(needle_start, page_ptr + offset, chunk_size) != 0) { return false; @@ -134,7 +134,7 @@ struct EffectiveAddressSpaceAccessors : Accessors return (needle_size == 0); } - std::optional<u32> Search(u32 haystack_start, u8* needle_start, u32 needle_size, + std::optional<u32> Search(u32 haystack_start, const u8* needle_start, std::size_t needle_size, bool forward) const override { u32 haystack_address = haystack_start; @@ -190,7 +190,7 @@ struct AuxiliaryAddressSpaceAccessors : Accessors iterator end() const override { return DSP::GetARAMPtr() + GetSize(); } - std::optional<u32> Search(u32 haystack_offset, u8* needle_start, u32 needle_size, + std::optional<u32> Search(u32 haystack_offset, const u8* needle_start, std::size_t needle_size, bool forward) const override { if (!IsValidAddress(haystack_offset)) @@ -264,7 +264,7 @@ struct CompositeAddressSpaceAccessors : Accessors return it->accessors->WriteU8(address, value); } - std::optional<u32> Search(u32 haystack_offset, u8* needle_start, u32 needle_size, + std::optional<u32> Search(u32 haystack_offset, const u8* needle_start, std::size_t needle_size, bool forward) const override { for (const AccessorMapping& mapping : m_accessor_mappings) @@ -320,10 +320,11 @@ struct SmallBlockAccessors : Accessors return (*alloc_base == nullptr) ? nullptr : (*alloc_base + size); } - std::optional<u32> Search(u32 haystack_offset, u8* needle_start, u32 needle_size, + std::optional<u32> Search(u32 haystack_offset, const u8* needle_start, std::size_t needle_size, bool forward) const override { - if (!IsValidAddress(haystack_offset) || !IsValidAddress(haystack_offset + needle_size - 1)) + if (!IsValidAddress(haystack_offset) || + !IsValidAddress(haystack_offset + static_cast<u32>(needle_size) - 1)) { return std::nullopt; } diff --git a/Source/Core/Core/HW/AddressSpace.h b/Source/Core/Core/HW/AddressSpace.h index a02989010a..9577669bdc 100644 --- a/Source/Core/Core/HW/AddressSpace.h +++ b/Source/Core/Core/HW/AddressSpace.h @@ -40,8 +40,8 @@ struct Accessors virtual iterator begin() const; virtual iterator end() const; - virtual std::optional<u32> Search(u32 haystack_offset, u8* needle_start, u32 needle_size, - bool forward) const; + virtual std::optional<u32> Search(u32 haystack_offset, const u8* needle_start, + std::size_t needle_size, bool forward) const; virtual ~Accessors(); }; |
