diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 2f2312761f..8596a3514a 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -93,7 +93,7 @@ public: template void PushMoveObjects(std::shared_ptr... pointers); - void PushStaticBuffer(const std::vector& buffer, u8 buffer_id); + void PushStaticBuffer(std::vector buffer, u8 buffer_id); /// Pushes an HLE MappedBuffer interface back to unmapped the buffer. void PushMappedBuffer(const Kernel::MappedBuffer& mapped_buffer); @@ -193,14 +193,14 @@ inline void RequestBuilder::PushMoveObjects(std::shared_ptr... pointers) { PushMoveHLEHandles(context->AddOutgoingHandle(std::move(pointers))...); } -inline void RequestBuilder::PushStaticBuffer(const std::vector& buffer, u8 buffer_id) { +inline void RequestBuilder::PushStaticBuffer(std::vector buffer, u8 buffer_id) { ASSERT_MSG(buffer_id < MAX_STATIC_BUFFERS, "Invalid static buffer id"); Push(StaticBufferDesc(buffer.size(), buffer_id)); // This address will be replaced by the correct static buffer address during IPC translation. Push(0xDEADC0DE); - context->AddStaticBuffer(buffer_id, buffer); + context->AddStaticBuffer(buffer_id, std::move(buffer)); } inline void RequestBuilder::PushMappedBuffer(const Kernel::MappedBuffer& mapped_buffer) { diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index dce84e94b4..e5d8746633 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1307,7 +1307,7 @@ void Module::Interface::GetDependencyListFromCia(Kernel::HLERequestContext& ctx) IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); - rb.PushStaticBuffer(buffer, 0); + rb.PushStaticBuffer(std::move(buffer), 0); } void Module::Interface::GetTransferSizeFromCia(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index 6612a720e4..88763787c4 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -209,10 +209,11 @@ ResultVal AppletManager::GlanceParameter(AppletId app_id) { // Note: The NS module always clears the DSPSleep and DSPWakeup signals even in GlanceParameter. if (next_parameter->signal == SignalType::DspSleep || - next_parameter->signal == SignalType::DspWakeup) + next_parameter->signal == SignalType::DspWakeup) { next_parameter = {}; + } - return MakeResult(parameter); + return MakeResult(std::move(parameter)); } ResultVal AppletManager::ReceiveParameter(AppletId app_id) { diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index b9c8628bfb..8ce9a0ca1d 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -357,8 +357,8 @@ void Module::APTInterface::SendParameter(Kernel::HLERequestContext& ctx) { void Module::APTInterface::ReceiveParameter(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0xD, 2, 0); // 0xD0080 - AppletId app_id = rp.PopEnum(); - u32 buffer_size = rp.Pop(); + const auto app_id = rp.PopEnum(); + const u32 buffer_size = rp.Pop(); LOG_DEBUG(Service_APT, "called app_id={:#010X}, buffer_size={:#010X}", static_cast(app_id), buffer_size); @@ -379,14 +379,14 @@ void Module::APTInterface::ReceiveParameter(Kernel::HLERequestContext& ctx) { ASSERT_MSG(next_parameter->buffer.size() <= buffer_size, "Input static buffer is too small!"); rb.Push(static_cast(next_parameter->buffer.size())); // Parameter buffer size rb.PushMoveObjects(next_parameter->object); - next_parameter->buffer.resize(buffer_size, 0); // APT always push a buffer with the maximum size - rb.PushStaticBuffer(next_parameter->buffer, 0); + next_parameter->buffer.resize(buffer_size); // APT always push a buffer with the maximum size + rb.PushStaticBuffer(std::move(next_parameter->buffer), 0); } void Module::APTInterface::GlanceParameter(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0xE, 2, 0); // 0xE0080 - AppletId app_id = rp.PopEnum(); - u32 buffer_size = rp.Pop(); + const auto app_id = rp.PopEnum(); + const u32 buffer_size = rp.Pop(); LOG_DEBUG(Service_APT, "called app_id={:#010X}, buffer_size={:#010X}", static_cast(app_id), buffer_size); @@ -406,8 +406,8 @@ void Module::APTInterface::GlanceParameter(Kernel::HLERequestContext& ctx) { ASSERT_MSG(next_parameter->buffer.size() <= buffer_size, "Input static buffer is too small!"); rb.Push(static_cast(next_parameter->buffer.size())); // Parameter buffer size rb.PushMoveObjects(next_parameter->object); - next_parameter->buffer.resize(buffer_size, 0); // APT always push a buffer with the maximum size - rb.PushStaticBuffer(next_parameter->buffer, 0); + next_parameter->buffer.resize(buffer_size); // APT always push a buffer with the maximum size + rb.PushStaticBuffer(std::move(next_parameter->buffer), 0); } void Module::APTInterface::CancelParameter(Kernel::HLERequestContext& ctx) { @@ -779,9 +779,8 @@ void Module::APTInterface::GetAppletInfo(Kernel::HLERequestContext& ctx) { void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x51, 2, 0); // 0x00510080 u32 parameter_size = rp.Pop(); - StartupArgumentType startup_argument_type = static_cast(rp.Pop()); - - const u32 max_parameter_size{0x1000}; + constexpr u32 max_parameter_size{0x1000}; + const auto startup_argument_type = static_cast(rp.Pop()); if (parameter_size > max_parameter_size) { LOG_ERROR(Service_APT, @@ -791,7 +790,7 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) { parameter_size = max_parameter_size; } - std::vector parameter(parameter_size, 0); + std::vector parameter(parameter_size); LOG_WARNING(Service_APT, "(STUBBED) called, startup_argument_type={}, parameter_size={:#010X}", static_cast(startup_argument_type), parameter_size); @@ -799,7 +798,7 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(0); - rb.PushStaticBuffer(parameter, 0); + rb.PushStaticBuffer(std::move(parameter), 0); } void Module::APTInterface::Wrap(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index c093ed7e55..491fbd3268 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -936,7 +936,7 @@ void Module::Interface::GetLatestVsyncTiming(Kernel::HLERequestContext& ctx) { break; } } - rb.PushStaticBuffer(out, 0); + rb.PushStaticBuffer(std::move(out), 0); } void Module::Interface::GetStereoCameraCalibrationData(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index 9b0ef89866..dcfb73d6e1 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -155,13 +155,14 @@ void DSP_DSP::ReadPipeIfPossible(Kernel::HLERequestContext& ctx) { const u16 pipe_readable_size = static_cast(system.DSP().GetPipeReadableSize(pipe)); std::vector pipe_buffer; - if (pipe_readable_size >= size) + if (pipe_readable_size >= size) { pipe_buffer = system.DSP().PipeRead(pipe, size); + } IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(pipe_readable_size); - rb.PushStaticBuffer(pipe_buffer, 0); + rb.PushStaticBuffer(std::move(pipe_buffer), 0); LOG_DEBUG(Service_DSP, "channel={}, peer={}, size=0x{:04X}, pipe_readable_size=0x{:04X}", channel, peer, size, pipe_readable_size); diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 69f2a44625..bd408420d1 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -29,52 +29,52 @@ void Module::Interface::GetMyPresence(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); - rb.PushStaticBuffer(buffer, 0); + rb.PushStaticBuffer(std::move(buffer), 0); LOG_WARNING(Service_FRD, "(STUBBED) called"); } void Module::Interface::GetFriendKeyList(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x11, 2, 0); - u32 unknown = rp.Pop(); - u32 frd_count = rp.Pop(); + const u32 unknown = rp.Pop(); + const u32 frd_count = rp.Pop(); std::vector buffer(sizeof(FriendKey) * frd_count, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(0); // 0 friends - rb.PushStaticBuffer(buffer, 0); + rb.PushStaticBuffer(std::move(buffer), 0); LOG_WARNING(Service_FRD, "(STUBBED) called, unknown={}, frd_count={}", unknown, frd_count); } void Module::Interface::GetFriendProfile(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x15, 1, 2); - u32 count = rp.Pop(); - std::vector frd_keys = rp.PopStaticBuffer(); + const u32 count = rp.Pop(); + const std::vector frd_keys = rp.PopStaticBuffer(); ASSERT(frd_keys.size() == count * sizeof(FriendKey)); std::vector buffer(sizeof(Profile) * count, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); - rb.PushStaticBuffer(buffer, 0); + rb.PushStaticBuffer(std::move(buffer), 0); LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count); } void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x17, 1, 2); - u32 count = rp.Pop(); - std::vector frd_keys = rp.PopStaticBuffer(); + const u32 count = rp.Pop(); + const std::vector frd_keys = rp.PopStaticBuffer(); ASSERT(frd_keys.size() == count * sizeof(FriendKey)); // TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte std::vector buffer(1 * count, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); - rb.PushStaticBuffer(buffer, 0); + rb.PushStaticBuffer(std::move(buffer), 0); LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count); } @@ -111,7 +111,7 @@ void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx IPC::RequestParser rp(ctx, 0x1C, 1, 2); const u32 friend_code_count = rp.Pop(); - std::vector scrambled_friend_codes = rp.PopStaticBuffer(); + const std::vector scrambled_friend_codes = rp.PopStaticBuffer(); ASSERT_MSG(scrambled_friend_codes.size() == (friend_code_count * scrambled_friend_code_size), "Wrong input buffer size"); @@ -133,7 +133,7 @@ void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx LOG_WARNING(Service_FRD, "(STUBBED) called"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); - rb.PushStaticBuffer(unscrambled_friend_codes, 0); + rb.PushStaticBuffer(std::move(unscrambled_friend_codes), 0); } void Module::Interface::SetClientSdkVersion(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index ece6673967..11ac590425 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -1124,12 +1124,12 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) { } if (channel->second.received_packets.empty()) { - std::vector output_buffer(buff_size, 0); + std::vector output_buffer(buff_size); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); rb.Push(RESULT_SUCCESS); rb.Push(0); rb.Push(0); - rb.PushStaticBuffer(output_buffer, 0); + rb.PushStaticBuffer(std::move(output_buffer), 0); return; } @@ -1147,7 +1147,7 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); - std::vector output_buffer(buff_size, 0); + std::vector output_buffer(buff_size); // Write the actual data. std::memcpy(output_buffer.data(), next_packet.data() + sizeof(LLCHeader) + sizeof(SecureDataHeader), data_size); @@ -1155,7 +1155,7 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(data_size); rb.Push(secure_data.src_node_id); - rb.PushStaticBuffer(output_buffer, 0); + rb.PushStaticBuffer(std::move(output_buffer), 0); channel->second.received_packets.pop_front(); } @@ -1336,9 +1336,9 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx, u16 command_id) IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); - std::vector output_buffer(sizeof(NodeInfo) * UDSMaxNodes, 0); + std::vector output_buffer(sizeof(NodeInfo) * UDSMaxNodes); std::memcpy(output_buffer.data(), nodes.data(), sizeof(NodeInfo) * nodes.size()); - rb.PushStaticBuffer(output_buffer, 0); + rb.PushStaticBuffer(std::move(output_buffer), 0); } template diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index 56b48cd3a5..d45832a438 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -513,12 +513,13 @@ void SOC_U::Accept(Kernel::HLERequestContext& ctx) { socklen_t addr_len = sizeof(addr); u32 ret = static_cast(::accept(socket_handle, &addr, &addr_len)); - if ((s32)ret != SOCKET_ERROR_VALUE) + if (static_cast(ret) != SOCKET_ERROR_VALUE) { open_sockets[ret] = {ret, true}; + } CTRSockAddr ctr_addr; std::vector ctr_addr_buf(sizeof(ctr_addr)); - if ((s32)ret == SOCKET_ERROR_VALUE) { + if (static_cast(ret) == SOCKET_ERROR_VALUE) { ret = TranslateError(GET_ERRNO); } else { ctr_addr = CTRSockAddr::FromPlatform(addr); @@ -528,7 +529,7 @@ void SOC_U::Accept(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); - rb.PushStaticBuffer(ctr_addr_buf, 0); + rb.PushStaticBuffer(std::move(ctr_addr_buf), 0); } void SOC_U::GetHostId(Kernel::HLERequestContext& ctx) { @@ -636,7 +637,7 @@ void SOC_U::RecvFromOther(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 4); rb.Push(RESULT_SUCCESS); rb.Push(ret); - rb.PushStaticBuffer(addr_buff, 0); + rb.PushStaticBuffer(std::move(addr_buff), 0); rb.PushMappedBuffer(buffer); } @@ -685,8 +686,8 @@ void SOC_U::RecvFrom(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(ret); rb.Push(total_received); - rb.PushStaticBuffer(output_buff, 0); - rb.PushStaticBuffer(addr_buff, 1); + rb.PushStaticBuffer(std::move(output_buff), 0); + rb.PushStaticBuffer(std::move(addr_buff), 1); } void SOC_U::Poll(Kernel::HLERequestContext& ctx) { @@ -720,7 +721,7 @@ void SOC_U::Poll(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); - rb.PushStaticBuffer(output_fds, 0); + rb.PushStaticBuffer(std::move(output_fds), 0); } void SOC_U::GetSockName(Kernel::HLERequestContext& ctx) { @@ -743,7 +744,7 @@ void SOC_U::GetSockName(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); - rb.PushStaticBuffer(dest_addr_buff, 0); + rb.PushStaticBuffer(std::move(dest_addr_buff), 0); } void SOC_U::Shutdown(Kernel::HLERequestContext& ctx) { @@ -781,7 +782,7 @@ void SOC_U::GetPeerName(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); - rb.PushStaticBuffer(dest_addr_buff, 0); + rb.PushStaticBuffer(std::move(dest_addr_buff), 0); } void SOC_U::Connect(Kernel::HLERequestContext& ctx) { @@ -857,7 +858,7 @@ void SOC_U::GetSockOpt(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(err); rb.Push(static_cast(optlen)); - rb.PushStaticBuffer(optval, 0); + rb.PushStaticBuffer(std::move(optval), 0); } void SOC_U::SetSockOpt(Kernel::HLERequestContext& ctx) { @@ -948,7 +949,7 @@ void SOC_U::GetAddrInfoImpl(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(ret); rb.Push(count); - rb.PushStaticBuffer(out_buff, 0); + rb.PushStaticBuffer(std::move(out_buff), 0); } void SOC_U::GetNameInfoImpl(Kernel::HLERequestContext& ctx) { @@ -976,8 +977,8 @@ void SOC_U::GetNameInfoImpl(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 4); rb.Push(RESULT_SUCCESS); rb.Push(ret); - rb.PushStaticBuffer(host, 0); - rb.PushStaticBuffer(serv, 1); + rb.PushStaticBuffer(std::move(host), 0); + rb.PushStaticBuffer(std::move(serv), 1); } SOC_U::SOC_U() : ServiceFramework("soc:U") {