diff options
author | Lioncash <mathew1800@gmail.com> | 2022-11-23 19:25:14 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2022-11-23 19:43:20 +0100 |
commit | 97f273e94e83a679f42faa9c81916a1c058112e1 (patch) | |
tree | e2a2777ae3bec31b544516988fae36e8080150ff /src/core/hle/service/es/es.cpp | |
parent | hle_ipc: Add helper functions for getting number of buffer elements (diff) | |
download | yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.gz yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.bz2 yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.lz yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.xz yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.zst yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.zip |
Diffstat (limited to 'src/core/hle/service/es/es.cpp')
-rw-r--r-- | src/core/hle/service/es/es.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index ff9b0427c..d183e5829 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp @@ -192,12 +192,10 @@ private: } void ListCommonTicketRightsIds(Kernel::HLERequestContext& ctx) { - u32 out_entries; - if (keys.GetCommonTickets().empty()) - out_entries = 0; - else - out_entries = static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(u128)); - + size_t out_entries = 0; + if (!keys.GetCommonTickets().empty()) { + out_entries = ctx.GetWriteBufferNumElements<u128>(); + } LOG_DEBUG(Service_ETicket, "called, entries={:016X}", out_entries); keys.PopulateTickets(); @@ -206,20 +204,19 @@ private: std::transform(tickets.begin(), tickets.end(), std::back_inserter(ids), [](const auto& pair) { return pair.first; }); - out_entries = static_cast<u32>(std::min<std::size_t>(ids.size(), out_entries)); + out_entries = std::min(ids.size(), out_entries); ctx.WriteBuffer(ids.data(), out_entries * sizeof(u128)); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push<u32>(out_entries); + rb.Push<u32>(static_cast<u32>(out_entries)); } void ListPersonalizedTicketRightsIds(Kernel::HLERequestContext& ctx) { - u32 out_entries; - if (keys.GetPersonalizedTickets().empty()) - out_entries = 0; - else - out_entries = static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(u128)); + size_t out_entries = 0; + if (!keys.GetPersonalizedTickets().empty()) { + out_entries = ctx.GetWriteBufferNumElements<u128>(); + } LOG_DEBUG(Service_ETicket, "called, entries={:016X}", out_entries); @@ -229,12 +226,12 @@ private: std::transform(tickets.begin(), tickets.end(), std::back_inserter(ids), [](const auto& pair) { return pair.first; }); - out_entries = static_cast<u32>(std::min<std::size_t>(ids.size(), out_entries)); + out_entries = std::min(ids.size(), out_entries); ctx.WriteBuffer(ids.data(), out_entries * sizeof(u128)); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push<u32>(out_entries); + rb.Push<u32>(static_cast<u32>(out_entries)); } void GetCommonTicketSize(Kernel::HLERequestContext& ctx) { |