From dfa582169bfeec61f0e4c01545a7e3c290210d0d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 May 2020 13:29:06 -0400 Subject: kernel/memory: Resolve -Wshadow warnings Prevents variable name clashing. --- src/core/hle/kernel/memory/memory_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/hle/kernel/memory/memory_manager.cpp b/src/core/hle/kernel/memory/memory_manager.cpp index 3cd4f9e85..6b432e1b2 100644 --- a/src/core/hle/kernel/memory/memory_manager.cpp +++ b/src/core/hle/kernel/memory/memory_manager.cpp @@ -104,9 +104,9 @@ ResultCode MemoryManager::Allocate(PageLinkedList& page_list, std::size_t num_pa // Ensure that we don't leave anything un-freed auto group_guard = detail::ScopeExit([&] { for (const auto& it : page_list.Nodes()) { - const auto num_pages{std::min( + const auto min_num_pages{std::min( it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; - chosen_manager.Free(it.GetAddress(), num_pages); + chosen_manager.Free(it.GetAddress(), min_num_pages); } }); @@ -165,9 +165,9 @@ ResultCode MemoryManager::Free(PageLinkedList& page_list, std::size_t num_pages, // Free all of the pages for (const auto& it : page_list.Nodes()) { - const auto num_pages{std::min( + const auto min_num_pages{std::min( it.GetNumPages(), (chosen_manager.GetEndAddress() - it.GetAddress()) / PageSize)}; - chosen_manager.Free(it.GetAddress(), num_pages); + chosen_manager.Free(it.GetAddress(), min_num_pages); } return RESULT_SUCCESS; -- cgit v1.2.3 From 26aee55aef18acddf2b922191cc1f5bbb7724c03 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 May 2020 13:34:21 -0400 Subject: kernel/memory: Make use of std::array consistently in address_space_info This allows tuning standard library implementations to enable or disable range checks at runtime, which is nicer for debugging. --- src/core/hle/kernel/memory/address_space_info.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/hle/kernel/memory/address_space_info.cpp b/src/core/hle/kernel/memory/address_space_info.cpp index 27fae05e7..ca226e885 100644 --- a/src/core/hle/kernel/memory/address_space_info.cpp +++ b/src/core/hle/kernel/memory/address_space_info.cpp @@ -49,18 +49,18 @@ constexpr bool IsAllowedIndexForAddress(std::size_t index) { return index < std::size(AddressSpaceInfos) && AddressSpaceInfos[index].GetAddress() != Invalid; } -constexpr std::size_t - AddressSpaceIndices32Bit[static_cast(AddressSpaceInfo::Type::Count)]{ +constexpr std::array(AddressSpaceInfo::Type::Count)> + AddressSpaceIndices32Bit{ 0, 1, 0, 2, 0, 3, }; -constexpr std::size_t - AddressSpaceIndices36Bit[static_cast(AddressSpaceInfo::Type::Count)]{ +constexpr std::array(AddressSpaceInfo::Type::Count)> + AddressSpaceIndices36Bit{ 4, 5, 4, 6, 4, 7, }; -constexpr std::size_t - AddressSpaceIndices39Bit[static_cast(AddressSpaceInfo::Type::Count)]{ +constexpr std::array(AddressSpaceInfo::Type::Count)> + AddressSpaceIndices39Bit{ 9, 8, 8, 10, 12, 11, }; -- cgit v1.2.3 From a2e61e6542d55c9c6e416b8974264018bf5e726f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 May 2020 13:36:18 -0400 Subject: kernel/memory: Remove unused variables in memory_block_manager Prevents unused variable warnings. --- src/core/hle/kernel/memory/memory_block_manager.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/core/hle/kernel/memory/memory_block_manager.cpp b/src/core/hle/kernel/memory/memory_block_manager.cpp index 900395c37..0732fa5a1 100644 --- a/src/core/hle/kernel/memory/memory_block_manager.cpp +++ b/src/core/hle/kernel/memory/memory_block_manager.cpp @@ -67,7 +67,6 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState p MemoryPermission prev_perm, MemoryAttribute prev_attribute, MemoryState state, MemoryPermission perm, MemoryAttribute attribute) { - const std::size_t prev_count{memory_block_tree.size()}; const VAddr end_addr{addr + num_pages * PageSize}; iterator node{memory_block_tree.begin()}; @@ -109,7 +108,6 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState p void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState state, MemoryPermission perm, MemoryAttribute attribute) { - const std::size_t prev_count{memory_block_tree.size()}; const VAddr end_addr{addr + num_pages * PageSize}; iterator node{memory_block_tree.begin()}; @@ -145,7 +143,6 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState s void MemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc&& lock_func, MemoryPermission perm) { - const std::size_t prev_count{memory_block_tree.size()}; const VAddr end_addr{addr + num_pages * PageSize}; iterator node{memory_block_tree.begin()}; -- cgit v1.2.3 From 1ecaa86a520642c008c7d566d33fa39146435aee Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 May 2020 13:41:15 -0400 Subject: kernel/memory: Remove unused includes Prevents header churn and needing to recompile these files if these headers are ever changed in the future. --- src/core/hle/kernel/memory/address_space_info.h | 1 - src/core/hle/kernel/memory/memory_block_manager.h | 1 - src/core/hle/kernel/memory/memory_manager.h | 1 - src/core/hle/kernel/memory/page_linked_list.h | 1 - src/core/hle/kernel/memory/page_table.cpp | 1 - src/core/hle/kernel/memory/page_table.h | 3 +-- src/core/hle/kernel/memory/slab_heap.h | 1 - 7 files changed, 1 insertion(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/hle/kernel/memory/address_space_info.h b/src/core/hle/kernel/memory/address_space_info.h index cc9a6421e..6c5e1aab4 100644 --- a/src/core/hle/kernel/memory/address_space_info.h +++ b/src/core/hle/kernel/memory/address_space_info.h @@ -7,7 +7,6 @@ #pragma once -#include "common/common_funcs.h" #include "common/common_types.h" namespace Kernel::Memory { diff --git a/src/core/hle/kernel/memory/memory_block_manager.h b/src/core/hle/kernel/memory/memory_block_manager.h index 9451b5df6..6e1d41075 100644 --- a/src/core/hle/kernel/memory/memory_block_manager.h +++ b/src/core/hle/kernel/memory/memory_block_manager.h @@ -6,7 +6,6 @@ #include #include -#include #include "common/common_types.h" #include "core/hle/kernel/memory/memory_block.h" diff --git a/src/core/hle/kernel/memory/memory_manager.h b/src/core/hle/kernel/memory/memory_manager.h index b078d7a5e..3cf444857 100644 --- a/src/core/hle/kernel/memory/memory_manager.h +++ b/src/core/hle/kernel/memory/memory_manager.h @@ -7,7 +7,6 @@ #include #include -#include "common/common_funcs.h" #include "common/common_types.h" #include "core/hle/kernel/memory/page_heap.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/memory/page_linked_list.h b/src/core/hle/kernel/memory/page_linked_list.h index 0668d00c6..45dc13eaf 100644 --- a/src/core/hle/kernel/memory/page_linked_list.h +++ b/src/core/hle/kernel/memory/page_linked_list.h @@ -7,7 +7,6 @@ #include #include "common/assert.h" -#include "common/common_funcs.h" #include "common/common_types.h" #include "core/hle/kernel/memory/memory_types.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp index 3281611f8..5d6aac00f 100644 --- a/src/core/hle/kernel/memory/page_table.cpp +++ b/src/core/hle/kernel/memory/page_table.cpp @@ -6,7 +6,6 @@ #include "common/assert.h" #include "common/scope_exit.h" #include "core/core.h" -#include "core/device_memory.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/memory/address_space_info.h" diff --git a/src/core/hle/kernel/memory/page_table.h b/src/core/hle/kernel/memory/page_table.h index a867aa050..ce0d38849 100644 --- a/src/core/hle/kernel/memory/page_table.h +++ b/src/core/hle/kernel/memory/page_table.h @@ -4,16 +4,15 @@ #pragma once -#include #include #include -#include "common/common_funcs.h" #include "common/common_types.h" #include "common/page_table.h" #include "core/file_sys/program_metadata.h" #include "core/hle/kernel/memory/memory_block.h" #include "core/hle/kernel/memory/memory_manager.h" +#include "core/hle/result.h" namespace Core { class System; diff --git a/src/core/hle/kernel/memory/slab_heap.h b/src/core/hle/kernel/memory/slab_heap.h index be95fc3f7..a0244025f 100644 --- a/src/core/hle/kernel/memory/slab_heap.h +++ b/src/core/hle/kernel/memory/slab_heap.h @@ -10,7 +10,6 @@ #include #include "common/assert.h" -#include "common/common_funcs.h" #include "common/common_types.h" namespace Kernel::Memory { -- cgit v1.2.3 From 4620580245b33f81f1b4e2c923fe1160c4533508 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 May 2020 13:42:04 -0400 Subject: kernel/memory: Remove #pragma once within cpp file This isn't necessary in a cpp file and will cause warnings on clang. --- src/core/hle/kernel/memory/system_control.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/core/hle/kernel/memory/system_control.cpp b/src/core/hle/kernel/memory/system_control.cpp index 9cae3c6cb..2f98e9c4c 100644 --- a/src/core/hle/kernel/memory/system_control.cpp +++ b/src/core/hle/kernel/memory/system_control.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - #include #include "core/hle/kernel/memory/system_control.h" -- cgit v1.2.3