From 37b75f0928f0d0170538459a78100d7320ef8e78 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Mon, 19 Jun 2023 20:10:43 -0700 Subject: [PATCH] Fix `C4267`/`C4244` warnings Address warnings involving lossy conversions from larger integer-types into smaller integer-types --- include/PICA/gpu.hpp | 2 +- include/memory.hpp | 16 ++--- src/core/fs/archive_ncch.cpp | 8 +-- src/core/fs/archive_self_ncch.cpp | 12 ++-- src/core/kernel/file_operations.cpp | 8 +-- src/core/kernel/threads.cpp | 4 +- src/core/loader/lz77.cpp | 2 +- src/core/memory.cpp | 94 +++++++++++++--------------- src/core/renderer_gl/renderer_gl.cpp | 2 +- src/core/services/dsp.cpp | 4 +- src/core/services/fs.cpp | 8 +-- 11 files changed, 77 insertions(+), 83 deletions(-) diff --git a/include/PICA/gpu.hpp b/include/PICA/gpu.hpp index 2de48c01..a4adc816 100644 --- a/include/PICA/gpu.hpp +++ b/include/PICA/gpu.hpp @@ -26,7 +26,7 @@ class GPU { MAKE_LOG_FUNCTION(log, gpuLogger) static constexpr u32 maxAttribCount = 12; // Up to 12 vertex attributes - static constexpr u32 vramSize = 6_MB; + static constexpr u32 vramSize = u32(6_MB); Registers regs; // GPU internal registers std::array currentAttributes; // Vertex attributes before being passed to the shader diff --git a/include/memory.hpp b/include/memory.hpp index 40349b46..6f33d895 100644 --- a/include/memory.hpp +++ b/include/memory.hpp @@ -110,7 +110,7 @@ class Memory { std::vector memoryInfo; std::array sharedMemBlocks = { - SharedMemoryBlock(0, _shared_font_len, KernelHandles::FontSharedMemHandle), // Shared memory for the system font + SharedMemoryBlock(0, u32(_shared_font_len), KernelHandles::FontSharedMemHandle), // Shared memory for the system font SharedMemoryBlock(0, 0x1000, KernelHandles::GSPSharedMemHandle), // GSP shared memory SharedMemoryBlock(0, 0x1000, KernelHandles::HIDSharedMemHandle) // HID shared memory }; @@ -121,14 +121,14 @@ public: static constexpr u32 pageMask = pageSize - 1; static constexpr u32 totalPageCount = 1 << (32 - pageShift); - static constexpr u32 FCRAM_SIZE = 128_MB; - static constexpr u32 FCRAM_APPLICATION_SIZE = 64_MB; + static constexpr u32 FCRAM_SIZE = u32(128_MB); + static constexpr u32 FCRAM_APPLICATION_SIZE = u32(64_MB); static constexpr u32 FCRAM_PAGE_COUNT = FCRAM_SIZE / pageSize; static constexpr u32 FCRAM_APPLICATION_PAGE_COUNT = FCRAM_APPLICATION_SIZE / pageSize; - static constexpr u32 DSP_RAM_SIZE = 512_KB; - static constexpr u32 DSP_CODE_MEMORY_OFFSET = 0_KB; - static constexpr u32 DSP_DATA_MEMORY_OFFSET = 256_KB; + static constexpr u32 DSP_RAM_SIZE = u32(512_KB); + static constexpr u32 DSP_CODE_MEMORY_OFFSET = u32(0_KB); + static constexpr u32 DSP_DATA_MEMORY_OFFSET = u32(256_KB); private: std::bitset usedFCRAMPages; @@ -141,8 +141,8 @@ private: public: u16 kernelVersion = 0; - u32 usedUserMemory = 0_MB; // How much of the APPLICATION FCRAM range is used (allocated to the appcore) - u32 usedSystemMemory = 0_MB; // Similar for the SYSTEM range (reserved for the syscore) + u32 usedUserMemory = u32(0_MB); // How much of the APPLICATION FCRAM range is used (allocated to the appcore) + u32 usedSystemMemory = u32(0_MB); // Similar for the SYSTEM range (reserved for the syscore) Memory(u64& cpuTicks); void reset(); diff --git a/src/core/fs/archive_ncch.cpp b/src/core/fs/archive_ncch.cpp index 3a3330b8..6684ccf4 100644 --- a/src/core/fs/archive_ncch.cpp +++ b/src/core/fs/archive_ncch.cpp @@ -138,8 +138,8 @@ std::optional NCCHArchive::readFile(FileSession* file, u64 offset, u32 size // Seek to file offset depending on if we're reading from RomFS, ExeFS, etc switch (type) { case PathType::RomFS: { - const u32 romFSSize = cxi->romFS.size; - const u32 romFSOffset = cxi->romFS.offset; + const u64 romFSSize = cxi->romFS.size; + const u64 romFSOffset = cxi->romFS.offset; if ((offset >> 32) || (offset >= romFSSize) || (offset + size >= romFSSize)) { Helpers::panic("Tried to read from NCCH with too big of an offset"); } @@ -161,8 +161,8 @@ std::optional NCCHArchive::readFile(FileSession* file, u64 offset, u32 size } for (u64 i = 0; i < bytesRead; i++) { - mem.write8(dataPointer + i, data[i]); + mem.write8(u32(dataPointer + i), data[i]); } - return bytesRead; + return u32(bytesRead); } \ No newline at end of file diff --git a/src/core/fs/archive_self_ncch.cpp b/src/core/fs/archive_self_ncch.cpp index fa141b03..9b3aff29 100644 --- a/src/core/fs/archive_self_ncch.cpp +++ b/src/core/fs/archive_self_ncch.cpp @@ -76,8 +76,8 @@ std::optional SelfNCCHArchive::readFile(FileSession* file, u64 offset, u32 // Seek to file offset depending on if we're reading from RomFS, ExeFS, etc switch (type) { case PathType::RomFS: { - const u32 romFSSize = cxi->romFS.size; - const u32 romFSOffset = cxi->romFS.offset; + const u64 romFSSize = cxi->romFS.size; + const u64 romFSOffset = cxi->romFS.offset; if ((offset >> 32) || (offset >= romFSSize) || (offset + size >= romFSSize)) { Helpers::panic("Tried to read from SelfNCCH with too big of an offset"); } @@ -88,8 +88,8 @@ std::optional SelfNCCHArchive::readFile(FileSession* file, u64 offset, u32 } case PathType::ExeFS: { - const u32 exeFSSize = cxi->exeFS.size; - const u32 exeFSOffset = cxi->exeFS.offset; + const u64 exeFSSize = cxi->exeFS.size; + const u64 exeFSOffset = cxi->exeFS.offset; if ((offset >> 32) || (offset >= exeFSSize) || (offset + size >= exeFSSize)) { Helpers::panic("Tried to read from SelfNCCH with too big of an offset"); } @@ -110,8 +110,8 @@ std::optional SelfNCCHArchive::readFile(FileSession* file, u64 offset, u32 } for (u64 i = 0; i < bytesRead; i++) { - mem.write8(dataPointer + i, data[i]); + mem.write8(u32(dataPointer + i), data[i]); } - return bytesRead; + return u32(bytesRead); } \ No newline at end of file diff --git a/src/core/kernel/file_operations.cpp b/src/core/kernel/file_operations.cpp index 455e9fc2..c7837100 100644 --- a/src/core/kernel/file_operations.cpp +++ b/src/core/kernel/file_operations.cpp @@ -97,11 +97,11 @@ void Kernel::readFile(u32 messagePointer, Handle fileHandle) { } else { for (size_t i = 0; i < bytesRead; i++) { - mem.write8(dataPointer + i, data[i]); + mem.write8(u32(dataPointer + i), data[i]); } mem.write32(messagePointer + 4, Result::Success); - mem.write32(messagePointer + 8, bytesRead); + mem.write32(messagePointer + 8, u32(bytesRead)); } return; @@ -142,7 +142,7 @@ void Kernel::writeFile(u32 messagePointer, Handle fileHandle) { std::unique_ptr data(new u8[size]); for (size_t i = 0; i < size; i++) { - data[i] = mem.read8(dataPointer + i); + data[i] = mem.read8(u32(dataPointer + i)); } IOFile f(file->fd); @@ -153,7 +153,7 @@ void Kernel::writeFile(u32 messagePointer, Handle fileHandle) { Helpers::panic("Kernel::WriteFile failed"); } else { mem.write32(messagePointer + 4, Result::Success); - mem.write32(messagePointer + 8, bytesWritten); + mem.write32(messagePointer + 8, u32(bytesWritten)); } } diff --git a/src/core/kernel/threads.cpp b/src/core/kernel/threads.cpp index c8325031..587d5fc4 100644 --- a/src/core/kernel/threads.cpp +++ b/src/core/kernel/threads.cpp @@ -286,7 +286,7 @@ int Kernel::wakeupOneThread(u64 waitlist, Handle handle) { // Get the index of the event in the object's waitlist, write it to r1 for (size_t i = 0; i < t.waitList.size(); i++) { if (t.waitList[i] == handle) { - t.gprs[1] = i; + t.gprs[1] = u32(i); break; } } @@ -321,7 +321,7 @@ void Kernel::wakeupAllThreads(u64 waitlist, Handle handle) { // Get the index of the event in the object's waitlist, write it to r1 for (size_t i = 0; i < t.waitList.size(); i++) { if (t.waitList[i] == handle) { - t.gprs[1] = i; + t.gprs[1] = u32(i); break; } } diff --git a/src/core/loader/lz77.cpp b/src/core/loader/lz77.cpp index 254053fd..60021b13 100644 --- a/src/core/loader/lz77.cpp +++ b/src/core/loader/lz77.cpp @@ -12,7 +12,7 @@ u32 CartLZ77::decompressedSize(const u8* buffer, u32 compressedSize) { } bool CartLZ77::decompress(std::vector& output, const std::vector& input) { - u32 sizeCompressed = input.size() * sizeof(u8); + u32 sizeCompressed = u32(input.size() * sizeof(u8)); u32 sizeDecompressed = decompressedSize(input); output.resize(sizeDecompressed); diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 00f28eba..1b14baaa 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -1,9 +1,11 @@ #include "memory.hpp" + +#include +#include // For time since epoch +#include + #include "config_mem.hpp" #include "resource_limits.hpp" -#include -#include // For time since epoch -#include using namespace KernelMemoryTypes; @@ -13,15 +15,15 @@ Memory::Memory(u64& cpuTicks) : cpuTicks(cpuTicks) { readTable.resize(totalPageCount, 0); writeTable.resize(totalPageCount, 0); - memoryInfo.reserve(32); // Pre-allocate some room for memory allocation info to avoid dynamic allocs + memoryInfo.reserve(32); // Pre-allocate some room for memory allocation info to avoid dynamic allocs } void Memory::reset() { // Unallocate all memory memoryInfo.clear(); usedFCRAMPages.reset(); - usedUserMemory = 0_MB; - usedSystemMemory = 0_MB; + usedUserMemory = u32(0_MB); + usedSystemMemory = u32(0_MB); for (u32 i = 0; i < totalPageCount; i++) { readTable[i] = 0; @@ -35,7 +37,7 @@ void Memory::reset() { } u32 basePaddrForTLS = tlsBaseOpt.value(); - for (int i = 0; i < appResourceLimits.maxThreads; i++) { + for (u32 i = 0; i < appResourceLimits.maxThreads; i++) { u32 vaddr = VirtualAddrs::TLSBase + i * VirtualAddrs::TLSSize; allocateMemory(vaddr, basePaddrForTLS, VirtualAddrs::TLSSize, true); basePaddrForTLS += VirtualAddrs::TLSSize; @@ -48,8 +50,8 @@ void Memory::reset() { } // Map DSP RAM as R/W at [0x1FF00000, 0x1FF7FFFF] - constexpr u32 dspRamPages = DSP_RAM_SIZE / pageSize; // Number of DSP RAM pages - constexpr u32 initialPage = VirtualAddrs::DSPMemStart / pageSize; // First page of DSP RAM in the virtual address space + constexpr u32 dspRamPages = DSP_RAM_SIZE / pageSize; // Number of DSP RAM pages + constexpr u32 initialPage = VirtualAddrs::DSPMemStart / pageSize; // First page of DSP RAM in the virtual address space for (u32 i = 0; i < dspRamPages; i++) { auto pointer = uintptr_t(&dspRam[i * pageSize]); @@ -67,7 +69,7 @@ bool Memory::allocateMainThreadStack(u32 size) { } const u32 stackBottom = VirtualAddrs::StackTop - size; - std::optional result = allocateMemory(stackBottom, basePaddr.value(), size, true); // Should never be nullopt + std::optional result = allocateMemory(stackBottom, basePaddr.value(), size, true); // Should never be nullopt return result.has_value(); } @@ -78,18 +80,17 @@ u8 Memory::read8(u32 vaddr) { uintptr_t pointer = readTable[page]; if (pointer != 0) [[likely]] { return *(u8*)(pointer + offset); - } - else { + } else { switch (vaddr) { case ConfigMem::BatteryState: return getBatteryState(true, true, BatteryLevel::FourBars); case ConfigMem::EnvInfo: return envInfo; case ConfigMem::HardwareType: return ConfigMem::HardwareCodes::Product; case ConfigMem::KernelVersionMinor: return u8(kernelVersion & 0xff); case ConfigMem::KernelVersionMajor: return u8(kernelVersion >> 8); - case ConfigMem::LedState3D: return 1; // Report the 3D LED as always off (non-zero) for now - case ConfigMem::NetworkState: return 2; // Report that we've got an internet connection + case ConfigMem::LedState3D: return 1; // Report the 3D LED as always off (non-zero) for now + case ConfigMem::NetworkState: return 2; // Report that we've got an internet connection case ConfigMem::HeadphonesConnectedMaybe: return 0; - case ConfigMem::Unknown1086: return 1; // It's unknown what this is but some games want it to be 1 + case ConfigMem::Unknown1086: return 1; // It's unknown what this is but some games want it to be 1 default: Helpers::panic("Unimplemented 8-bit read, addr: %08X", vaddr); } } @@ -102,8 +103,7 @@ u16 Memory::read16(u32 vaddr) { uintptr_t pointer = readTable[page]; if (pointer != 0) [[likely]] { return *(u16*)(pointer + offset); - } - else { + } else { Helpers::panic("Unimplemented 16-bit read, addr: %08X", vaddr); } } @@ -117,18 +117,20 @@ u32 Memory::read32(u32 vaddr) { return *(u32*)(pointer + offset); } else { switch (vaddr) { - case ConfigMem::Datetime0: return u32(timeSince3DSEpoch()); // ms elapsed since Jan 1 1900, bottom 32 bits - case ConfigMem::Datetime0 + 4: return u32(timeSince3DSEpoch() >> 32); // top 32 bits + case ConfigMem::Datetime0: return u32(timeSince3DSEpoch()); // ms elapsed since Jan 1 1900, bottom 32 bits + case ConfigMem::Datetime0 + 4: + return u32(timeSince3DSEpoch() >> 32); // top 32 bits // Ticks since time was last updated. For now we return the current tick count case ConfigMem::Datetime0 + 8: return u32(cpuTicks); case ConfigMem::Datetime0 + 12: return u32(cpuTicks >> 32); - case ConfigMem::Datetime0 + 16: return 0xFFB0FF0; // Unknown, set by PTM - case ConfigMem::Datetime0 + 20: case ConfigMem::Datetime0 + 24: case ConfigMem::Datetime0 + 28: - return 0; // Set to 0 by PTM + case ConfigMem::Datetime0 + 16: return 0xFFB0FF0; // Unknown, set by PTM + case ConfigMem::Datetime0 + 20: + case ConfigMem::Datetime0 + 24: + case ConfigMem::Datetime0 + 28: return 0; // Set to 0 by PTM case ConfigMem::AppMemAlloc: return appResourceLimits.maxCommit; case ConfigMem::SyscoreVer: return 2; - case 0x1FF81000: return 0; // TODO: Figure out what this config mem address does + case 0x1FF81000: return 0; // TODO: Figure out what this config mem address does default: if (vaddr >= VirtualAddrs::VramStart && vaddr < VirtualAddrs::VramStart + VirtualAddrs::VramSize) { Helpers::warn("VRAM read!\n"); @@ -154,13 +156,12 @@ void Memory::write8(u32 vaddr, u8 value) { uintptr_t pointer = writeTable[page]; if (pointer != 0) [[likely]] { *(u8*)(pointer + offset) = value; - } - else { + } else { // VRAM write if (vaddr >= VirtualAddrs::VramStart && vaddr < VirtualAddrs::VramStart + VirtualAddrs::VramSize) { // TODO: Invalidate renderer caches here vram[vaddr - VirtualAddrs::VramStart] = value; - } + } else { Helpers::panic("Unimplemented 8-bit write, addr: %08X, val: %02X", vaddr, value); @@ -219,11 +220,10 @@ void* Memory::getWritePointer(u32 address) { std::string Memory::readString(u32 address, u32 maxSize) { std::string string; string.reserve(maxSize); - + for (std::size_t i = 0; i < maxSize; ++i) { char c = read8(address++); - if (c == '\0') - break; + if (c == '\0') break; string.push_back(c); } string.shrink_to_fit(); @@ -233,12 +233,9 @@ std::string Memory::readString(u32 address, u32 maxSize) { // Return a pointer to the linear heap vaddr based on the kernel ver, because it needed to be moved // thanks to the New 3DS having more FCRAM -u32 Memory::getLinearHeapVaddr() { - return (kernelVersion < 0x22C) ? VirtualAddrs::LinearHeapStartOld : VirtualAddrs::LinearHeapStartNew; -} +u32 Memory::getLinearHeapVaddr() { return (kernelVersion < 0x22C) ? VirtualAddrs::LinearHeapStartOld : VirtualAddrs::LinearHeapStartNew; } -std::optional Memory::allocateMemory(u32 vaddr, u32 paddr, u32 size, bool linear, bool r, bool w, bool x, - bool adjustAddrs, bool isMap) { +std::optional Memory::allocateMemory(u32 vaddr, u32 paddr, u32 size, bool linear, bool r, bool w, bool x, bool adjustAddrs, bool isMap) { // Kernel-allocated memory & size must always be aligned to a page boundary // Additionally assert we don't OoM and that we don't try to allocate physical FCRAM past what's available to userland // If we're mapping there's no fear of OoM, because we're not really allocating memory, just binding vaddrs to specific paddrs @@ -259,8 +256,7 @@ std::optional Memory::allocateMemory(u32 vaddr, u32 paddr, u32 size, bool l // Non-linear allocation needs special handling if (paddr == 0 && adjustAddrs) { std::optional newPaddr = findPaddr(size); - if (!newPaddr.has_value()) - Helpers::panic("Failed to find paddr"); + if (!newPaddr.has_value()) Helpers::panic("Failed to find paddr"); paddr = newPaddr.value(); assert(paddr + size <= FCRAM_APPLICATION_SIZE || isMap); @@ -281,12 +277,11 @@ std::optional Memory::allocateMemory(u32 vaddr, u32 paddr, u32 size, bool l } } - if (!isMap) - usedUserMemory += size; + if (!isMap) usedUserMemory += size; // Do linear mapping u32 virtualPage = vaddr >> pageShift; - u32 physPage = paddr >> pageShift; // TODO: Special handle when non-linear mapping is necessary + u32 physPage = paddr >> pageShift; // TODO: Special handle when non-linear mapping is necessary for (u32 i = 0; i < neededPageCount; i++) { if (r) { readTable[virtualPage] = uintptr_t(&fcram[physPage * pageSize]); @@ -320,11 +315,10 @@ std::optional Memory::findPaddr(u32 size) { u32 counter = 0; for (u32 i = 0; i < FCRAM_APPLICATION_PAGE_COUNT; i++) { - if (usedFCRAMPages[i]) { // Page is occupied already, go to new candidate + if (usedFCRAMPages[i]) { // Page is occupied already, go to new candidate candidatePage = i + 1; counter = 0; - } - else { // The paddr we're testing has 1 more free page + } else { // The paddr we're testing has 1 more free page counter++; // Check if there's enough free memory to use this page // We use == instead of >= because some software does 0-byte allocations @@ -351,12 +345,12 @@ u32 Memory::allocateSysMemory(u32 size) { Helpers::panic("Memory::allocateSysMemory: Overflowed OS FCRAM"); } - const u32 pageCount = size / pageSize; // Number of pages that will be used up - const u32 startIndex = sysFCRAMIndex() + usedSystemMemory; // Starting FCRAM index + const u32 pageCount = size / pageSize; // Number of pages that will be used up + const u32 startIndex = sysFCRAMIndex() + usedSystemMemory; // Starting FCRAM index const u32 startingPage = startIndex / pageSize; for (u32 i = 0; i < pageCount; i++) { - if (usedFCRAMPages[startingPage + i]) // Also a theoretically unreachable panic for safety + if (usedFCRAMPages[startingPage + i]) // Also a theoretically unreachable panic for safety Helpers::panic("Memory::reserveMemory: Trying to reserve already reserved memory"); usedFCRAMPages[startingPage + i] = true; } @@ -419,7 +413,7 @@ void Memory::mirrorMapping(u32 destAddress, u32 sourceAddress, u32 size) { // Should theoretically be unreachable, only here for safety purposes assert(isAligned(destAddress) && isAligned(sourceAddress) && isAligned(size)); - const u32 pageCount = size / pageSize; // How many pages we need to mirror + const u32 pageCount = size / pageSize; // How many pages we need to mirror for (u32 i = 0; i < pageCount; i++) { // Redo the shift here to "properly" handle wrapping around the address space instead of reading OoB const u32 sourcePage = sourceAddress / pageSize; @@ -437,16 +431,16 @@ void Memory::mirrorMapping(u32 destAddress, u32 sourceAddress, u32 size) { u64 Memory::timeSince3DSEpoch() { using namespace std::chrono; - std::time_t rawTime = std::time(nullptr); // Get current UTC time - auto localTime = std::localtime(&rawTime); // Convert to local time + std::time_t rawTime = std::time(nullptr); // Get current UTC time + auto localTime = std::localtime(&rawTime); // Convert to local time - bool daylightSavings = localTime->tm_isdst > 0; // Get if time includes DST + bool daylightSavings = localTime->tm_isdst > 0; // Get if time includes DST localTime = std::gmtime(&rawTime); // Use gmtime + mktime to calculate difference between local time and UTC auto timezoneDifference = rawTime - std::mktime(localTime); if (daylightSavings) { - timezoneDifference += 60ull * 60ull; // Add 1 hour (60 seconds * 60 minutes) + timezoneDifference += 60ull * 60ull; // Add 1 hour (60 seconds * 60 minutes) } // seconds between Jan 1 1900 and Jan 1 1970 diff --git a/src/core/renderer_gl/renderer_gl.cpp b/src/core/renderer_gl/renderer_gl.cpp index 73fb0919..54d2485a 100644 --- a/src/core/renderer_gl/renderer_gl.cpp +++ b/src/core/renderer_gl/renderer_gl.cpp @@ -911,7 +911,7 @@ void Renderer::drawVertices(PICA::PrimType primType, std::span ver } vbo.bufferVertsSub(vertices); - OpenGL::draw(primitiveTopology, vertices.size()); + OpenGL::draw(primitiveTopology, GLsizei(vertices.size())); } constexpr u32 topScreenBuffer = 0x1f000000; diff --git a/src/core/services/dsp.cpp b/src/core/services/dsp.cpp index 376a08a0..69eb9fb3 100644 --- a/src/core/services/dsp.cpp +++ b/src/core/services/dsp.cpp @@ -143,7 +143,7 @@ std::vector DSPService::readPipe(u32 pipe, u32 size) { } std::vector& data = pipeData[pipe]; - size = std::min(size, data.size()); // Clamp size to the maximum available data size + size = std::min(size, u32(data.size())); // Clamp size to the maximum available data size if (size == 0) return {}; @@ -168,7 +168,7 @@ void DSPService::readPipeIfPossible(u32 messagePointer) { } mem.write32(messagePointer + 4, Result::Success); - mem.write16(messagePointer + 8, data.size()); // Number of bytes read + mem.write16(messagePointer + 8, u16(data.size())); // Number of bytes read } void DSPService::recvData(u32 messagePointer) { diff --git a/src/core/services/fs.cpp b/src/core/services/fs.cpp index 2fd3b8e6..7b64b234 100644 --- a/src/core/services/fs.cpp +++ b/src/core/services/fs.cpp @@ -219,7 +219,7 @@ void FSService::openArchive(u32 messagePointer) { } void FSService::openFile(u32 messagePointer) { - const Handle archiveHandle = mem.read64(messagePointer + 8); + const Handle archiveHandle = Handle(mem.read64(messagePointer + 8)); const u32 filePathType = mem.read32(messagePointer + 16); const u32 filePathSize = mem.read32(messagePointer + 20); const u32 openFlags = mem.read32(messagePointer + 24); @@ -342,7 +342,7 @@ void FSService::openFileDirectly(u32 messagePointer) { } void FSService::createFile(u32 messagePointer) { - const Handle archiveHandle = mem.read64(messagePointer + 8); + const Handle archiveHandle = Handle(mem.read64(messagePointer + 8)); const u32 filePathType = mem.read32(messagePointer + 16); const u32 filePathSize = mem.read32(messagePointer + 20); const u32 attributes = mem.read32(messagePointer + 24); @@ -367,7 +367,7 @@ void FSService::createFile(u32 messagePointer) { } void FSService::deleteFile(u32 messagePointer) { - const Handle archiveHandle = mem.read64(messagePointer + 8); + const Handle archiveHandle = Handle(mem.read64(messagePointer + 8)); const u32 filePathType = mem.read32(messagePointer + 16); const u32 filePathSize = mem.read32(messagePointer + 20); const u32 filePathPointer = mem.read32(messagePointer + 28); @@ -478,7 +478,7 @@ void FSService::formatThisUserSaveData(u32 messagePointer) { } void FSService::controlArchive(u32 messagePointer) { - const Handle archiveHandle = mem.read64(messagePointer + 4); + const Handle archiveHandle = Handle(mem.read64(messagePointer + 4)); const u32 action = mem.read32(messagePointer + 12); const u32 inputSize = mem.read32(messagePointer + 16); const u32 outputSize = mem.read32(messagePointer + 20);