From 3a43475149dabce8ad7a0ad5f01136bb50befdf9 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 12 May 2022 00:23:36 -0400 Subject: [PATCH] core: Resolve C4267 warning on MSVC --- src/core/dumping/backend.cpp | 3 ++- src/core/dumping/ffmpeg_backend.cpp | 2 +- src/core/file_sys/seed_db.cpp | 2 +- src/core/hle/kernel/ipc.cpp | 5 +++-- src/core/hle/kernel/thread.cpp | 11 ++++++----- src/core/hle/service/dsp/dsp_dsp.cpp | 2 +- src/core/hle/service/nfc/nfc.cpp | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/core/dumping/backend.cpp b/src/core/dumping/backend.cpp index 88686b7a2..16cd1d908 100644 --- a/src/core/dumping/backend.cpp +++ b/src/core/dumping/backend.cpp @@ -8,7 +8,8 @@ namespace VideoDumper { VideoFrame::VideoFrame(std::size_t width_, std::size_t height_, u8* data_) - : width(width_), height(height_), stride(width * 4), data(data_, data_ + width * height * 4) {} + : width(width_), height(height_), stride(static_cast(width * 4)), + data(data_, data_ + width * height * 4) {} Backend::~Backend() = default; NullBackend::~NullBackend() = default; diff --git a/src/core/dumping/ffmpeg_backend.cpp b/src/core/dumping/ffmpeg_backend.cpp index 28c33639b..cad321d87 100644 --- a/src/core/dumping/ffmpeg_backend.cpp +++ b/src/core/dumping/ffmpeg_backend.cpp @@ -354,7 +354,7 @@ void FFmpegAudioStream::ProcessFrame(const VariableAudioFrame& channel0, } auto resampled_count = swr_convert(swr_context.get(), dst_data.data(), frame_size - offset, - src_data.data(), channel0.size()); + src_data.data(), static_cast(channel0.size())); if (resampled_count < 0) { LOG_ERROR(Render, "Audio frame dropped: Could not resample data"); return; diff --git a/src/core/file_sys/seed_db.cpp b/src/core/file_sys/seed_db.cpp index f5b38fb0e..1e29a203b 100644 --- a/src/core/file_sys/seed_db.cpp +++ b/src/core/file_sys/seed_db.cpp @@ -143,7 +143,7 @@ u32 GetSeedCount() { if (!db.Load()) { return 0; } - return db.GetCount(); + return static_cast(db.GetCount()); } } // namespace FileSys diff --git a/src/core/hle/kernel/ipc.cpp b/src/core/hle/kernel/ipc.cpp index ca7bce97e..817f58216 100644 --- a/src/core/hle/kernel/ipc.cpp +++ b/src/core/hle/kernel/ipc.cpp @@ -209,7 +209,8 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy target_address = dst_process->vm_manager .MapBackingMemoryToBase(Memory::IPC_MAPPING_VADDR, Memory::IPC_MAPPING_SIZE, - buffer, buffer->GetSize(), Kernel::MemoryState::Shared) + buffer, static_cast(buffer->GetSize()), + Kernel::MemoryState::Shared) .Unwrap(); cmd_buf[i++] = target_address + page_offset; @@ -217,7 +218,7 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy // Reserve a page of memory after the mapped buffer dst_process->vm_manager.MapBackingMemoryToBase( Memory::IPC_MAPPING_VADDR, Memory::IPC_MAPPING_SIZE, reserve_buffer, - reserve_buffer->GetSize(), Kernel::MemoryState::Reserved); + static_cast(reserve_buffer->GetSize()), Kernel::MemoryState::Reserved); mapped_buffer_context.push_back({permissions, size, source_address, target_address + page_offset, std::move(buffer), diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 2920dc2ce..0d1d8d6ff 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -389,15 +389,16 @@ ResultVal> KernelSystem::CreateThread( auto& vm_manager = owner_process->vm_manager; // Map the page to the current process' address space. - vm_manager.MapBackingMemory(Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE, - memory.GetFCRAMRef(*offset), Memory::PAGE_SIZE, - MemoryState::Locked); + vm_manager.MapBackingMemory( + Memory::TLS_AREA_VADDR + static_cast(available_page) * Memory::PAGE_SIZE, + memory.GetFCRAMRef(*offset), Memory::PAGE_SIZE, MemoryState::Locked); } // Mark the slot as used tls_slots[available_page].set(available_slot); - thread->tls_address = Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE + - available_slot * Memory::TLS_ENTRY_SIZE; + thread->tls_address = Memory::TLS_AREA_VADDR + + static_cast(available_page) * Memory::PAGE_SIZE + + static_cast(available_slot) * Memory::TLS_ENTRY_SIZE; memory.ZeroBlock(*owner_process, thread->tls_address, Memory::TLS_ENTRY_SIZE); diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index ff6fecb3b..607b4a363 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -161,7 +161,7 @@ void DSP_DSP::ReadPipeIfPossible(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); - rb.Push(pipe_buffer.size()); + rb.Push(static_cast(pipe_buffer.size())); rb.PushStaticBuffer(std::move(pipe_buffer), 0); LOG_DEBUG(Service_DSP, "channel={}, peer={}, size=0x{:04X}, pipe_readable_size=0x{:04X}", diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index e02a5ad0a..388ea771f 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -141,7 +141,7 @@ void Module::Interface::GetTagInfo(Kernel::HLERequestContext& ctx) { TagInfo tag_info{}; tag_info.uuid = nfc->amiibo_data.uuid; - tag_info.id_offset_size = tag_info.uuid.size(); + tag_info.id_offset_size = static_cast(tag_info.uuid.size()); tag_info.unk1 = 0x0; tag_info.unk2 = 0x2;