service: Use ReadBufferSpan where it is trivial to do so
This commit is contained in:
parent
fbc375f0de
commit
7ffd624248
31 changed files with 78 additions and 77 deletions
|
|
@ -346,7 +346,6 @@ std::vector<u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const {
|
|||
}
|
||||
|
||||
std::span<const u8> HLERequestContext::ReadBufferSpan(std::size_t buffer_index) const {
|
||||
LOG_CRITICAL(Debug, "called");
|
||||
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
|
||||
BufferDescriptorA()[buffer_index].Size()};
|
||||
if (is_buffer_a) {
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ protected:
|
|||
IPC::RequestParser rp{ctx};
|
||||
const auto base = rp.PopRaw<ProfileBase>();
|
||||
|
||||
const auto user_data = ctx.ReadBuffer();
|
||||
const auto user_data = ctx.ReadBufferSpan();
|
||||
|
||||
LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}",
|
||||
Common::StringFromFixedZeroTerminatedBuffer(
|
||||
|
|
@ -399,8 +399,8 @@ protected:
|
|||
IPC::RequestParser rp{ctx};
|
||||
const auto base = rp.PopRaw<ProfileBase>();
|
||||
|
||||
const auto user_data = ctx.ReadBuffer();
|
||||
const auto image_data = ctx.ReadBuffer(1);
|
||||
const auto user_data = ctx.ReadBufferSpan();
|
||||
const auto image_data = ctx.ReadBufferSpan(1);
|
||||
|
||||
LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}",
|
||||
Common::StringFromFixedZeroTerminatedBuffer(
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestParser rp{ctx};
|
||||
|
||||
const u64 offset{rp.Pop<u64>()};
|
||||
const std::vector<u8> data{ctx.ReadBuffer()};
|
||||
const auto data{ctx.ReadBufferSpan()};
|
||||
const std::size_t size{std::min<u64>(data.size(), backing.GetSize() - offset)};
|
||||
|
||||
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ private:
|
|||
IPC::RequestParser rp{ctx};
|
||||
|
||||
const auto unknown_1 = rp.Pop<u64>();
|
||||
[[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer();
|
||||
[[maybe_unused]] const auto unknown_2 = ctx.ReadBufferSpan();
|
||||
|
||||
LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1);
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ private:
|
|||
IPC::RequestParser rp{ctx};
|
||||
|
||||
const auto unknown_1 = rp.Pop<u64>();
|
||||
[[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer();
|
||||
[[maybe_unused]] const auto unknown_2 = ctx.ReadBufferSpan();
|
||||
|
||||
LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1);
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ private:
|
|||
LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioInBuffer!");
|
||||
}
|
||||
|
||||
const auto& in_buffer = ctx.ReadBuffer();
|
||||
const auto& in_buffer = ctx.ReadBufferSpan();
|
||||
AudioInBuffer buffer{};
|
||||
std::memcpy(&buffer, in_buffer.data(), sizeof(AudioInBuffer));
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestParser rp{ctx};
|
||||
auto in_params{rp.PopRaw<AudioInParameter>()};
|
||||
auto applet_resource_user_id{rp.PopRaw<u64>()};
|
||||
const auto device_name_data{ctx.ReadBuffer()};
|
||||
const auto device_name_data{ctx.ReadBufferSpan()};
|
||||
auto device_name = Common::StringFromBuffer(device_name_data);
|
||||
auto handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ void AudInU::OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx) {
|
|||
auto protocol_specified{rp.PopRaw<u64>()};
|
||||
auto in_params{rp.PopRaw<AudioInParameter>()};
|
||||
auto applet_resource_user_id{rp.PopRaw<u64>()};
|
||||
const auto device_name_data{ctx.ReadBuffer()};
|
||||
const auto device_name_data{ctx.ReadBufferSpan()};
|
||||
auto device_name = Common::StringFromBuffer(device_name_data);
|
||||
auto handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ private:
|
|||
LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioOutBuffer!");
|
||||
}
|
||||
|
||||
const auto& in_buffer = ctx.ReadBuffer();
|
||||
const auto& in_buffer = ctx.ReadBufferSpan();
|
||||
AudioOutBuffer buffer{};
|
||||
std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer));
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestParser rp{ctx};
|
||||
auto in_params{rp.PopRaw<AudioOutParameter>()};
|
||||
auto applet_resource_user_id{rp.PopRaw<u64>()};
|
||||
const auto device_name_data{ctx.ReadBuffer()};
|
||||
const auto device_name_data{ctx.ReadBufferSpan()};
|
||||
auto device_name = Common::StringFromBuffer(device_name_data);
|
||||
auto handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ private:
|
|||
void RequestUpdate(Kernel::HLERequestContext& ctx) {
|
||||
LOG_TRACE(Service_Audio, "called");
|
||||
|
||||
std::vector<u8> input{ctx.ReadBuffer(0)};
|
||||
const auto input{ctx.ReadBufferSpan(0)};
|
||||
|
||||
// These buffers are written manually to avoid an issue with WriteBuffer throwing errors for
|
||||
// checking size 0. Performance size is 0 for most games.
|
||||
|
|
@ -306,7 +306,7 @@ private:
|
|||
IPC::RequestParser rp{ctx};
|
||||
const f32 volume = rp.Pop<f32>();
|
||||
|
||||
const auto device_name_buffer = ctx.ReadBuffer();
|
||||
const auto device_name_buffer = ctx.ReadBufferSpan();
|
||||
const std::string name = Common::StringFromBuffer(device_name_buffer);
|
||||
|
||||
LOG_DEBUG(Service_Audio, "called. name={}, volume={}", name, volume);
|
||||
|
|
@ -320,7 +320,7 @@ private:
|
|||
}
|
||||
|
||||
void GetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) {
|
||||
const auto device_name_buffer = ctx.ReadBuffer();
|
||||
const auto device_name_buffer = ctx.ReadBufferSpan();
|
||||
const std::string name = Common::StringFromBuffer(device_name_buffer);
|
||||
|
||||
LOG_DEBUG(Service_Audio, "called. Name={}", name);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ private:
|
|||
ResetDecoderContext();
|
||||
}
|
||||
|
||||
if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) {
|
||||
if (!DecodeOpusData(consumed, sample_count, ctx.ReadBufferSpan(), samples, performance)) {
|
||||
LOG_ERROR(Audio, "Failed to decode opus data");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
// TODO(ogniK): Use correct error code
|
||||
|
|
@ -93,7 +93,7 @@ private:
|
|||
ctx.WriteBuffer(samples);
|
||||
}
|
||||
|
||||
bool DecodeOpusData(u32& consumed, u32& sample_count, const std::vector<u8>& input,
|
||||
bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input,
|
||||
std::vector<opus_int16>& output, u64* out_performance_time) const {
|
||||
const auto start_time = std::chrono::steady_clock::now();
|
||||
const std::size_t raw_output_sz = output.size() * sizeof(opus_int16);
|
||||
|
|
@ -257,7 +257,7 @@ void HwOpus::GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) {
|
||||
OpusMultiStreamParametersEx param;
|
||||
std::memcpy(¶m, ctx.ReadBuffer().data(), ctx.GetReadBufferSize());
|
||||
std::memcpy(¶m, ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize());
|
||||
|
||||
const auto sample_rate = param.sample_rate;
|
||||
const auto channel_count = param.channel_count;
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ private:
|
|||
IPC::RequestParser rp{ctx};
|
||||
const auto title_id = rp.PopRaw<u64>();
|
||||
|
||||
const auto passphrase_raw = ctx.ReadBuffer();
|
||||
const auto passphrase_raw = ctx.ReadBufferSpan();
|
||||
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id,
|
||||
Common::HexToString(passphrase_raw));
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ private:
|
|||
}
|
||||
|
||||
void ImportTicket(Kernel::HLERequestContext& ctx) {
|
||||
const auto ticket = ctx.ReadBuffer();
|
||||
const auto cert = ctx.ReadBuffer(1);
|
||||
const auto ticket = ctx.ReadBufferSpan();
|
||||
[[maybe_unused]] const auto cert = ctx.ReadBufferSpan(1);
|
||||
|
||||
if (ticket.size() < sizeof(Core::Crypto::Ticket)) {
|
||||
LOG_ERROR(Service_ETicket, "The input buffer is not large enough!");
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx)
|
|||
IPC::RequestParser rp(ctx);
|
||||
const auto error_code = rp.Pop<Result>();
|
||||
const auto fatal_type = rp.PopEnum<FatalType>();
|
||||
const auto fatal_info = ctx.ReadBuffer();
|
||||
const auto fatal_info = ctx.ReadBufferSpan();
|
||||
FatalInfo info{};
|
||||
|
||||
ASSERT_MSG(fatal_info.size() == sizeof(FatalInfo), "Invalid fatal info buffer size!");
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void NOTIF_A::RegisterAlarmSetting(Kernel::HLERequestContext& ctx) {
|
|||
"application_parameter_size is bigger than 0x400 bytes");
|
||||
|
||||
AlarmSetting new_alarm{};
|
||||
memcpy(&new_alarm, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
|
||||
memcpy(&new_alarm, ctx.ReadBufferSpan(0).data(), sizeof(AlarmSetting));
|
||||
|
||||
// TODO: Count alarms per game id
|
||||
if (alarms.size() >= max_alarms) {
|
||||
|
|
@ -73,7 +73,7 @@ void NOTIF_A::UpdateAlarmSetting(Kernel::HLERequestContext& ctx) {
|
|||
"application_parameter_size is bigger than 0x400 bytes");
|
||||
|
||||
AlarmSetting alarm_setting{};
|
||||
memcpy(&alarm_setting, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
|
||||
memcpy(&alarm_setting, ctx.ReadBufferSpan(0).data(), sizeof(AlarmSetting));
|
||||
|
||||
const auto alarm_it = GetAlarmFromId(alarm_setting.alarm_setting_id);
|
||||
if (alarm_it != alarms.end()) {
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
|||
return hid_core.GetSupportedStyleTag();
|
||||
}
|
||||
|
||||
void Controller_NPad::SetSupportedNpadIdTypes(u8* data, std::size_t length) {
|
||||
void Controller_NPad::SetSupportedNpadIdTypes(const u8* const data, std::size_t length) {
|
||||
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
||||
supported_npad_id_types.clear();
|
||||
supported_npad_id_types.resize(length / sizeof(u32));
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public:
|
|||
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
|
||||
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
||||
|
||||
void SetSupportedNpadIdTypes(u8* data, std::size_t length);
|
||||
void SetSupportedNpadIdTypes(const u8* const data, std::size_t length);
|
||||
void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
|
||||
std::size_t GetSupportedNpadIdTypesSize() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -1026,7 +1026,7 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
|
|||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||
.SetSupportedNpadIdTypes(ctx.ReadBuffer().data(), ctx.GetReadBufferSize());
|
||||
.SetSupportedNpadIdTypes(ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize());
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
|
|
@ -1564,8 +1564,8 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
const auto handles = ctx.ReadBuffer(0);
|
||||
const auto vibrations = ctx.ReadBuffer(1);
|
||||
const auto handles = ctx.ReadBufferSpan(0);
|
||||
const auto vibrations = ctx.ReadBufferSpan(1);
|
||||
|
||||
std::vector<Core::HID::VibrationDeviceHandle> vibration_device_handles(
|
||||
handles.size() / sizeof(Core::HID::VibrationDeviceHandle));
|
||||
|
|
@ -2104,7 +2104,7 @@ void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) {
|
|||
const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()};
|
||||
const auto unknown{rp.Pop<u64>()};
|
||||
|
||||
const auto buffer = ctx.ReadBuffer();
|
||||
[[maybe_unused]] const auto buffer = ctx.ReadBufferSpan();
|
||||
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}",
|
||||
connection_handle.npad_id, unknown);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public:
|
|||
const auto parameters{rp.PopRaw<InputParameters>()};
|
||||
|
||||
// Optional input/output buffers
|
||||
std::vector<u8> input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::vector<u8>()};
|
||||
const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBufferSpan() : std::span<const u8>()};
|
||||
std::vector<u8> output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0);
|
||||
|
||||
// Function call prototype:
|
||||
|
|
@ -132,7 +132,7 @@ public:
|
|||
const auto command{rp.PopRaw<u64>()};
|
||||
|
||||
// Optional input/output buffers
|
||||
std::vector<u8> input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::vector<u8>()};
|
||||
const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBufferSpan() : std::span<const u8>()};
|
||||
std::vector<u8> output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0);
|
||||
|
||||
// Function call prototype:
|
||||
|
|
@ -176,7 +176,7 @@ public:
|
|||
IPC::RequestParser rp{ctx};
|
||||
const auto tmem_size{rp.PopRaw<u64>()};
|
||||
const auto tmem_handle{ctx.GetCopyHandle(0)};
|
||||
const auto nro_plugin{ctx.ReadBuffer(1)};
|
||||
const auto nro_plugin{ctx.ReadBufferSpan(1)};
|
||||
|
||||
if (tmem_size == 0) {
|
||||
LOG_ERROR(Service_JIT, "attempted to load plugin with empty transfer memory");
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ public:
|
|||
}
|
||||
|
||||
void SetAdvertiseData(Kernel::HLERequestContext& ctx) {
|
||||
std::vector<u8> read_buffer = ctx.ReadBuffer();
|
||||
const auto read_buffer = ctx.ReadBufferSpan();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(lan_discovery.SetAdvertiseData(read_buffer));
|
||||
|
|
@ -464,7 +464,7 @@ public:
|
|||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode, parameters.local_communication_version);
|
||||
|
||||
const std::vector<u8> read_buffer = ctx.ReadBuffer();
|
||||
const auto read_buffer = ctx.ReadBufferSpan();
|
||||
if (read_buffer.size() != sizeof(NetworkInfo)) {
|
||||
LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public:
|
|||
private:
|
||||
void Log(Kernel::HLERequestContext& ctx) {
|
||||
std::size_t offset{};
|
||||
const auto data = ctx.ReadBuffer();
|
||||
const auto data = ctx.ReadBufferSpan();
|
||||
|
||||
// This function only succeeds - Get that out of the way
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ void MFIUser::StopDetection(Kernel::HLERequestContext& ctx) {
|
|||
void MFIUser::Read(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto device_handle{rp.Pop<u64>()};
|
||||
const auto buffer{ctx.ReadBuffer()};
|
||||
const auto buffer{ctx.ReadBufferSpan()};
|
||||
const auto number_of_commands{ctx.GetReadBufferNumElements<NFP::MifareReadBlockParameter>()};
|
||||
std::vector<NFP::MifareReadBlockParameter> read_commands(number_of_commands);
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ void MFIUser::Read(Kernel::HLERequestContext& ctx) {
|
|||
void MFIUser::Write(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto device_handle{rp.Pop<u64>()};
|
||||
const auto buffer{ctx.ReadBuffer()};
|
||||
const auto buffer{ctx.ReadBufferSpan()};
|
||||
const auto number_of_commands{ctx.GetReadBufferNumElements<NFP::MifareWriteBlockParameter>()};
|
||||
std::vector<NFP::MifareWriteBlockParameter> write_commands(number_of_commands);
|
||||
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ void IUser::SendCommandByPassThrough(Kernel::HLERequestContext& ctx) {
|
|||
IPC::RequestParser rp{ctx};
|
||||
const auto device_handle{rp.Pop<u64>()};
|
||||
const auto timeout{rp.PopRaw<Time::Clock::TimeSpanType>()};
|
||||
const auto command_data{ctx.ReadBuffer()};
|
||||
const auto command_data{ctx.ReadBufferSpan()};
|
||||
|
||||
LOG_INFO(Service_NFC, "(STUBBED) called, device_handle={}, timeout={}, data_size={}",
|
||||
device_handle, timeout.ToSeconds(), command_data.size());
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue