2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

core: hle: kernel: k_page_table: Remove unnecessary casts.

This commit is contained in:
bunnei 2022-11-03 21:05:57 -07:00
parent 119315af08
commit 05ae0cab0e

View file

@ -79,10 +79,6 @@ public:
} }
}; };
} // namespace
namespace {
using namespace Common::Literals; using namespace Common::Literals;
constexpr size_t GetAddressSpaceWidthFromType(FileSys::ProgramAddressSpaceType as_type) { constexpr size_t GetAddressSpaceWidthFromType(FileSys::ProgramAddressSpaceType as_type) {
@ -784,10 +780,9 @@ Result KPageTable::SetupForIpcClient(PageLinkedList* page_list, size_t* out_bloc
R_UNLESS(this->Contains(address, size), ResultInvalidCurrentMemory); R_UNLESS(this->Contains(address, size), ResultInvalidCurrentMemory);
// Get the source permission. // Get the source permission.
const auto src_perm = static_cast<KMemoryPermission>( const auto src_perm = (test_perm == KMemoryPermission::UserReadWrite)
(test_perm == KMemoryPermission::UserReadWrite) ? KMemoryPermission::KernelReadWrite | KMemoryPermission::NotMapped
? KMemoryPermission::KernelReadWrite | KMemoryPermission::NotMapped : KMemoryPermission::UserRead;
: KMemoryPermission::UserRead);
// Get aligned extents. // Get aligned extents.
const VAddr aligned_src_start = Common::AlignDown((address), PageSize); const VAddr aligned_src_start = Common::AlignDown((address), PageSize);
@ -1162,10 +1157,9 @@ Result KPageTable::SetupForIpc(VAddr* out_dst_addr, size_t size, VAddr src_addr,
const size_t src_map_size = src_map_end - src_map_start; const size_t src_map_size = src_map_end - src_map_start;
// Ensure that we clean up appropriately if we fail after this. // Ensure that we clean up appropriately if we fail after this.
const auto src_perm = static_cast<KMemoryPermission>( const auto src_perm = (test_perm == KMemoryPermission::UserReadWrite)
(test_perm == KMemoryPermission::UserReadWrite) ? KMemoryPermission::KernelReadWrite | KMemoryPermission::NotMapped
? KMemoryPermission::KernelReadWrite | KMemoryPermission::NotMapped : KMemoryPermission::UserRead;
: KMemoryPermission::UserRead);
ON_RESULT_FAILURE { ON_RESULT_FAILURE {
if (src_map_end > src_map_start) { if (src_map_end > src_map_start) {
src_page_table.CleanupForIpcClientOnServerSetupFailure( src_page_table.CleanupForIpcClientOnServerSetupFailure(
@ -2735,8 +2729,7 @@ Result KPageTable::LockForIpcUserBuffer(PAddr* out, VAddr address, size_t size)
nullptr, out, address, size, KMemoryState::FlagCanIpcUserBuffer, nullptr, out, address, size, KMemoryState::FlagCanIpcUserBuffer,
KMemoryState::FlagCanIpcUserBuffer, KMemoryPermission::All, KMemoryState::FlagCanIpcUserBuffer, KMemoryPermission::All,
KMemoryPermission::UserReadWrite, KMemoryAttribute::All, KMemoryAttribute::None, KMemoryPermission::UserReadWrite, KMemoryAttribute::All, KMemoryAttribute::None,
static_cast<KMemoryPermission>(KMemoryPermission::NotMapped | KMemoryPermission::NotMapped | KMemoryPermission::KernelReadWrite,
KMemoryPermission::KernelReadWrite),
KMemoryAttribute::Locked)); KMemoryAttribute::Locked));
} }
@ -2752,9 +2745,7 @@ Result KPageTable::LockForCodeMemory(KPageGroup* out, VAddr addr, size_t size) {
R_RETURN(this->LockMemoryAndOpen( R_RETURN(this->LockMemoryAndOpen(
out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All, KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All,
KMemoryAttribute::None, KMemoryAttribute::None, KMemoryPermission::NotMapped | KMemoryPermission::KernelReadWrite,
static_cast<KMemoryPermission>(KMemoryPermission::NotMapped |
KMemoryPermission::KernelReadWrite),
KMemoryAttribute::Locked)); KMemoryAttribute::Locked));
} }