From be1954e04cb5a0c3a526f78ed5490a5e65310280 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 15 Oct 2020 14:49:45 -0400 Subject: core: Fix clang build Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795 --- .../hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 48 ++++++++++++---------- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 12 +++--- src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 8 ++-- src/core/hle/service/nvdrv/interface.cpp | 8 ++-- 4 files changed, 42 insertions(+), 34 deletions(-) (limited to 'src/core/hle/service/nvdrv') diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 39bd2a45b..85e921ceb 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -139,7 +139,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector& input, std::vector& ou const auto object{nvmap_dev->GetObject(params.nvmap_handle)}; if (!object) { - LOG_CRITICAL(Service_NVDRV, "invalid nvmap_handle={:X}", params.nvmap_handle); + LOG_ERROR(Service_NVDRV, "invalid nvmap_handle={:X}", params.nvmap_handle); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; } @@ -151,21 +151,24 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector& input, std::vector& ou auto& gpu = system.GPU(); u64 page_size{params.page_size}; - if (!page_size) { + if (page_size == 0) { page_size = object->align; } if ((params.flags & AddressSpaceFlags::Remap) != AddressSpaceFlags::None) { - if (const auto buffer_map{FindBufferMap(params.offset)}; buffer_map) { - const auto cpu_addr{static_cast(buffer_map->CpuAddr() + params.buffer_offset)}; + const auto buffer_map = FindBufferMap(static_cast(params.offset)); + + if (buffer_map) { + const auto cpu_addr{ + static_cast(buffer_map->CpuAddr() + static_cast(params.buffer_offset))}; const auto gpu_addr{static_cast(params.offset + params.buffer_offset)}; if (!gpu.MemoryManager().Map(cpu_addr, gpu_addr, params.mapping_size)) { - LOG_CRITICAL(Service_NVDRV, - "remap failed, flags={:X}, nvmap_handle={:X}, buffer_offset={}, " - "mapping_size = {}, offset={}", - params.flags, params.nvmap_handle, params.buffer_offset, - params.mapping_size, params.offset); + LOG_ERROR(Service_NVDRV, + "Remap failed, flags={:X}, nvmap_handle={:X}, buffer_offset={}, " + "mapping_size = {}, offset={}", + params.flags, params.nvmap_handle, params.buffer_offset, + params.mapping_size, params.offset); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; @@ -174,7 +177,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector& input, std::vector& ou std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::Success; } else { - LOG_CRITICAL(Service_NVDRV, "address not mapped offset={}", params.offset); + LOG_ERROR(Service_NVDRV, "Address not mapped. offset={}", params.offset); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; @@ -184,25 +187,27 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector& input, std::vector& ou // We can only map objects that have already been assigned a CPU address. ASSERT(object->status == nvmap::Object::Status::Allocated); - const auto physical_address{object->addr + params.buffer_offset}; + const auto physical_address{object->addr + static_cast(params.buffer_offset)}; u64 size{params.mapping_size}; - if (!size) { + if (size == 0) { size = object->size; } const bool is_alloc{(params.flags & AddressSpaceFlags::FixedOffset) == AddressSpaceFlags::None}; if (is_alloc) { - params.offset = gpu.MemoryManager().MapAllocate(physical_address, size, page_size); + params.offset = + static_cast(gpu.MemoryManager().MapAllocate(physical_address, size, page_size)); } else { - params.offset = gpu.MemoryManager().Map(physical_address, params.offset, size); + params.offset = static_cast( + gpu.MemoryManager().Map(physical_address, static_cast(params.offset), size)); } auto result{NvErrCodes::Success}; - if (!params.offset) { - LOG_CRITICAL(Service_NVDRV, "failed to map size={}", size); + if (params.offset == 0) { + LOG_ERROR(Service_NVDRV, "Failed to map size={}", size); result = NvErrCodes::InvalidInput; } else { - AddBufferMap(params.offset, size, physical_address, is_alloc); + AddBufferMap(static_cast(params.offset), size, physical_address, is_alloc); } std::memcpy(output.data(), ¶ms, output.size()); @@ -213,12 +218,13 @@ u32 nvhost_as_gpu::UnmapBuffer(const std::vector& input, std::vector& ou IoctlUnmapBuffer params{}; std::memcpy(¶ms, input.data(), input.size()); - LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", params.offset); + const auto offset = static_cast(params.offset); + LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", offset); - if (const auto size{RemoveBufferMap(params.offset)}; size) { - system.GPU().MemoryManager().Unmap(params.offset, *size); + if (const auto size{RemoveBufferMap(offset)}; size) { + system.GPU().MemoryManager().Unmap(offset, *size); } else { - LOG_ERROR(Service_NVDRV, "invalid offset=0x{:X}", params.offset); + LOG_ERROR(Service_NVDRV, "invalid offset=0x{:X}", offset); } std::memcpy(output.data(), ¶ms, output.size()); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index b27ee0502..07d851d0e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -63,8 +63,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& return NvResult::BadParameter; } - u32 event_id = params.value & 0x00FF; - + const u32 event_id = params.value & 0x00FF; if (event_id >= MaxNvEvents) { std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::BadParameter; @@ -78,16 +77,17 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& event.writable->Signal(); return NvResult::Success; } + auto lock = gpu.LockSync(); const u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); - const s32 diff = current_syncpoint_value - params.threshold; + const s32 diff = static_cast(current_syncpoint_value - params.threshold); if (diff >= 0) { event.writable->Signal(); params.value = current_syncpoint_value; std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::Success; } - const u32 target_value = current_syncpoint_value - diff; + const u32 target_value = current_syncpoint_value - static_cast(diff); if (!is_async) { params.value = 0; @@ -98,7 +98,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& return NvResult::Timeout; } - EventState status = events_interface.status[event_id]; + const EventState status = events_interface.status[event_id]; if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) { events_interface.SetEventStatus(event_id, EventState::Waiting); events_interface.assigned_syncpt[event_id] = params.syncpt_id; @@ -114,7 +114,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& if (!is_async && ctrl.fresh_call) { ctrl.must_delay = true; ctrl.timeout = params.timeout; - ctrl.event_id = event_id; + ctrl.event_id = static_cast(event_id); return NvResult::Timeout; } std::memcpy(output.data(), ¶ms, sizeof(params)); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index f1966ac0e..5e51b37be 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -127,7 +127,7 @@ u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector& input, std::vector& ou params.unk3); auto& gpu = system.GPU(); - params.fence_out.id = assigned_syncpoints; + params.fence_out.id = static_cast(assigned_syncpoints); params.fence_out.value = gpu.GetSyncpointValue(assigned_syncpoints); assigned_syncpoints++; std::memcpy(output.data(), ¶ms, output.size()); @@ -166,7 +166,8 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector& input, std::vector& outp UNIMPLEMENTED_IF(params.flags.add_increment.Value() != 0); auto& gpu = system.GPU(); - u32 current_syncpoint_value = gpu.GetSyncpointValue(params.fence_out.id); + const u32 current_syncpoint_value = + gpu.GetSyncpointValue(static_cast(params.fence_out.id)); if (params.flags.increment.Value()) { params.fence_out.value += current_syncpoint_value; } else { @@ -200,7 +201,8 @@ u32 nvhost_gpu::KickoffPB(const std::vector& input, std::vector& output, UNIMPLEMENTED_IF(params.flags.add_increment.Value() != 0); auto& gpu = system.GPU(); - u32 current_syncpoint_value = gpu.GetSyncpointValue(params.fence_out.id); + const u32 current_syncpoint_value = + gpu.GetSyncpointValue(static_cast(params.fence_out.id)); if (params.flags.increment.Value()) { params.fence_out.value += current_syncpoint_value; } else { diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 88fbfa9b0..2f4f73487 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -61,9 +61,9 @@ void NVDRV::IoctlBase(Kernel::HLERequestContext& ctx, IoctlVersion version) { if (ctrl.must_delay) { ctrl.fresh_call = false; ctx.SleepClientThread( - "NVServices::DelayedResponse", ctrl.timeout, - [=, this](std::shared_ptr thread, Kernel::HLERequestContext& ctx_, - Kernel::ThreadWakeupReason reason) { + "NVServices::DelayedResponse", static_cast(ctrl.timeout), + [=, this](std::shared_ptr, Kernel::HLERequestContext& ctx_, + Kernel::ThreadWakeupReason) { IoctlCtrl ctrl2{ctrl}; std::vector tmp_output = output; std::vector tmp_output2 = output2; @@ -77,7 +77,7 @@ void NVDRV::IoctlBase(Kernel::HLERequestContext& ctx, IoctlVersion version) { rb.Push(RESULT_SUCCESS); rb.Push(ioctl_result); }, - nvdrv->GetEventWriteable(ctrl.event_id)); + nvdrv->GetEventWriteable(static_cast(ctrl.event_id))); } else { ctx.WriteBuffer(output); if (version == IoctlVersion::Version3) { -- cgit v1.2.3