ams: globally prefer R_RETURN to return for ams::Result

This commit is contained in:
Michael Scire 2022-03-26 14:48:33 -07:00
parent dd78ede99f
commit bbf22b4c60
325 changed files with 1955 additions and 1993 deletions

View file

@ -122,19 +122,19 @@ namespace ams::htclow::ctrl {
switch (header.packet_type) {
case HtcctrlPacketType_ConnectFromHost:
return this->ProcessReceiveConnectPacket();
R_RETURN(this->ProcessReceiveConnectPacket());
case HtcctrlPacketType_ReadyFromHost:
return this->ProcessReceiveReadyPacket(body, body_size);
R_RETURN(this->ProcessReceiveReadyPacket(body, body_size));
case HtcctrlPacketType_SuspendFromHost:
return this->ProcessReceiveSuspendPacket();
R_RETURN(this->ProcessReceiveSuspendPacket());
case HtcctrlPacketType_ResumeFromHost:
return this->ProcessReceiveResumePacket();
R_RETURN(this->ProcessReceiveResumePacket());
case HtcctrlPacketType_DisconnectFromHost:
return this->ProcessReceiveDisconnectPacket();
R_RETURN(this->ProcessReceiveDisconnectPacket());
case HtcctrlPacketType_BeaconQuery:
return this->ProcessReceiveBeaconQueryPacket();
R_RETURN(this->ProcessReceiveBeaconQueryPacket());
default:
return this->ProcessReceiveUnexpectedPacket();
R_RETURN(this->ProcessReceiveUnexpectedPacket());
}
}
@ -142,7 +142,7 @@ namespace ams::htclow::ctrl {
/* Try to transition to sent connect state. */
if (R_FAILED(this->SetState(HtcctrlState_SentConnectFromHost))) {
/* We couldn't transition to sent connect. */
return this->ProcessReceiveUnexpectedPacket();
R_RETURN(this->ProcessReceiveUnexpectedPacket());
}
/* Send a connect packet. */
@ -160,7 +160,7 @@ namespace ams::htclow::ctrl {
/* Check that our version is correct. */
if (m_version < ProtocolVersion) {
return this->ProcessReceiveUnexpectedPacket();
R_RETURN(this->ProcessReceiveUnexpectedPacket());
}
/* Set our version. */
@ -169,7 +169,7 @@ namespace ams::htclow::ctrl {
/* Set our state. */
if (R_FAILED(this->SetState(HtcctrlState_SentReadyFromHost))) {
return this->ProcessReceiveUnexpectedPacket();
R_RETURN(this->ProcessReceiveUnexpectedPacket());
}
/* Ready ourselves. */
@ -181,7 +181,7 @@ namespace ams::htclow::ctrl {
/* Try to set our state to enter sleep. */
if (R_FAILED(this->SetState(HtcctrlState_EnterSleep))) {
/* We couldn't transition to sleep. */
return this->ProcessReceiveUnexpectedPacket();
R_RETURN(this->ProcessReceiveUnexpectedPacket());
}
R_SUCCEED();
@ -191,7 +191,7 @@ namespace ams::htclow::ctrl {
/* If our state is sent-resume, change to readied. */
if (m_state_machine->GetHtcctrlState() != HtcctrlState_SentResumeFromTarget || R_FAILED(this->SetState(HtcctrlState_Ready))) {
/* We couldn't perform a valid resume transition. */
return this->ProcessReceiveUnexpectedPacket();
R_RETURN(this->ProcessReceiveUnexpectedPacket());
}
R_SUCCEED();

View file

@ -226,7 +226,7 @@ namespace ams::htclow::driver {
}
/* Return our connection result. */
return m_connect_result;
R_RETURN(m_connect_result);
}
void SocketDriver::Shutdown() {

View file

@ -45,7 +45,7 @@ namespace ams::htclow::driver {
SetUsbAvailabilityChangeCallback(OnUsbAvailabilityChange, this);
/* Initialize the interface. */
return InitializeUsbInterface();
R_RETURN(InitializeUsbInterface());
}
void UsbDriver::Close() {

View file

@ -214,7 +214,7 @@ namespace ams::htclow::driver {
R_THROW(htclow::ResultUsbDriverUnknownError());
}
} else {
return result;
R_RETURN(result);
}
}

View file

@ -30,7 +30,7 @@ namespace ams::htclow {
};
/* Open the channel. */
return m_manager->Open(impl::ConvertChannelType(m_channel));
R_RETURN(m_manager->Open(impl::ConvertChannelType(m_channel)));
}
void Channel::Close() {
@ -56,7 +56,7 @@ namespace ams::htclow {
this->WaitEvent(m_manager->GetTaskEvent(task_id), false);
/* End the flush. */
return m_manager->ConnectEnd(channel, task_id);
R_RETURN(m_manager->ConnectEnd(channel, task_id));
}
Result Channel::Flush() {
@ -68,7 +68,7 @@ namespace ams::htclow {
this->WaitEvent(m_manager->GetTaskEvent(task_id), true);
/* End the flush. */
return m_manager->FlushEnd(task_id);
R_RETURN(m_manager->FlushEnd(task_id));
}
void Channel::Shutdown() {
@ -101,7 +101,7 @@ namespace ams::htclow {
if (htclow::ResultChannelNotExist::Includes(result)) {
*out = received;
}
return result;
R_RETURN(result);
}
received += static_cast<size_t>(cur_received);
@ -134,7 +134,7 @@ namespace ams::htclow {
if (total_sent != 0) {
break;
} else {
return begin_result;
R_RETURN(begin_result);
}
}
@ -172,7 +172,7 @@ namespace ams::htclow {
/* Check pre-conditions. */
AMS_ASSERT(util::IsIntValueRepresentable<size_t>(size));
return this->WaitReceiveInternal(size, nullptr);
R_RETURN(this->WaitReceiveInternal(size, nullptr));
}
Result Channel::WaitReceive(s64 size, os::EventType *event) {
@ -180,7 +180,7 @@ namespace ams::htclow {
AMS_ASSERT(util::IsIntValueRepresentable<size_t>(size));
AMS_ASSERT(event != nullptr);
return this->WaitReceiveInternal(size, event);
R_RETURN(this->WaitReceiveInternal(size, event));
}
void Channel::WaitEvent(os::EventType *event, bool) {
@ -229,7 +229,7 @@ namespace ams::htclow {
}
/* End the wait. */
return m_manager->WaitReceiveEnd(task_id);
R_RETURN(m_manager->WaitReceiveEnd(task_id));
}
}

View file

@ -29,7 +29,7 @@ namespace ams::htclow {
}
Result HtclowManager::OpenDriver(impl::DriverType driver_type) {
return m_impl->OpenDriver(driver_type);
R_RETURN(m_impl->OpenDriver(driver_type));
}
void HtclowManager::CloseDriver() {
@ -37,11 +37,11 @@ namespace ams::htclow {
}
Result HtclowManager::Open(impl::ChannelInternalType channel) {
return m_impl->Open(channel);
R_RETURN(m_impl->Open(channel));
}
Result HtclowManager::Close(impl::ChannelInternalType channel) {
return m_impl->Close(channel);
R_RETURN(m_impl->Close(channel));
}
void HtclowManager::Resume() {
@ -53,11 +53,11 @@ namespace ams::htclow {
}
Result HtclowManager::ConnectBegin(u32 *out_task_id, impl::ChannelInternalType channel) {
return m_impl->ConnectBegin(out_task_id, channel);
R_RETURN(m_impl->ConnectBegin(out_task_id, channel));
}
Result HtclowManager::ConnectEnd(impl::ChannelInternalType channel, u32 task_id) {
return m_impl->ConnectEnd(channel, task_id);
R_RETURN(m_impl->ConnectEnd(channel, task_id));
}
void HtclowManager::Disconnect() {
@ -65,11 +65,11 @@ namespace ams::htclow {
}
Result HtclowManager::FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel) {
return m_impl->FlushBegin(out_task_id, channel);
R_RETURN(m_impl->FlushBegin(out_task_id, channel));
}
Result HtclowManager::FlushEnd(u32 task_id) {
return m_impl->FlushEnd(task_id);
R_RETURN(m_impl->FlushEnd(task_id));
}
ChannelState HtclowManager::GetChannelState(impl::ChannelInternalType channel) {
@ -97,27 +97,27 @@ namespace ams::htclow {
}
Result HtclowManager::ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) {
return m_impl->ReceiveBegin(out_task_id, channel, size);
R_RETURN(m_impl->ReceiveBegin(out_task_id, channel, size));
}
Result HtclowManager::ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id) {
return m_impl->ReceiveEnd(out, dst, dst_size, channel, task_id);
R_RETURN(m_impl->ReceiveEnd(out, dst, dst_size, channel, task_id));
}
Result HtclowManager::SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel) {
return m_impl->SendBegin(out_task_id, out, src, src_size, channel);
R_RETURN(m_impl->SendBegin(out_task_id, out, src, src_size, channel));
}
Result HtclowManager::SendEnd(u32 task_id) {
return m_impl->SendEnd(task_id);
R_RETURN(m_impl->SendEnd(task_id));
}
Result HtclowManager::WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) {
return m_impl->WaitReceiveBegin(out_task_id, channel, size);
R_RETURN(m_impl->WaitReceiveBegin(out_task_id, channel, size));
}
Result HtclowManager::WaitReceiveEnd(u32 task_id) {
return m_impl->WaitReceiveEnd(task_id);
R_RETURN(m_impl->WaitReceiveEnd(task_id));
}
void HtclowManager::SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config) {
@ -141,7 +141,7 @@ namespace ams::htclow {
}
Result HtclowManager::Shutdown(impl::ChannelInternalType channel) {
return m_impl->Shutdown(channel);
R_RETURN(m_impl->Shutdown(channel));
}
}

View file

@ -75,11 +75,11 @@ namespace ams::htclow {
}
Result HtclowManagerImpl::Open(impl::ChannelInternalType channel) {
return m_mux.Open(channel);
R_RETURN(m_mux.Open(channel));
}
Result HtclowManagerImpl::Close(impl::ChannelInternalType channel) {
return m_mux.Close(channel);
R_RETURN(m_mux.Close(channel));
}
void HtclowManagerImpl::Resume() {
@ -118,7 +118,7 @@ namespace ams::htclow {
}
Result HtclowManagerImpl::ConnectEnd(impl::ChannelInternalType channel, u32 task_id) {
return m_mux.ConnectEnd(channel, task_id);
R_RETURN(m_mux.ConnectEnd(channel, task_id));
}
void HtclowManagerImpl::Disconnect() {
@ -126,11 +126,11 @@ namespace ams::htclow {
}
Result HtclowManagerImpl::FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel) {
return m_mux.FlushBegin(out_task_id, channel);
R_RETURN(m_mux.FlushBegin(out_task_id, channel));
}
Result HtclowManagerImpl::FlushEnd(u32 task_id) {
return m_mux.FlushEnd(task_id);
R_RETURN(m_mux.FlushEnd(task_id));
}
ChannelState HtclowManagerImpl::GetChannelState(impl::ChannelInternalType channel) {
@ -158,27 +158,27 @@ namespace ams::htclow {
}
Result HtclowManagerImpl::ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) {
return m_mux.ReceiveBegin(out_task_id, channel, size);
R_RETURN(m_mux.ReceiveBegin(out_task_id, channel, size));
}
Result HtclowManagerImpl::ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id) {
return m_mux.ReceiveEnd(out, dst, dst_size, channel, task_id);
R_RETURN(m_mux.ReceiveEnd(out, dst, dst_size, channel, task_id));
}
Result HtclowManagerImpl::SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel) {
return m_mux.SendBegin(out_task_id, out, src, src_size, channel);
R_RETURN(m_mux.SendBegin(out_task_id, out, src, src_size, channel));
}
Result HtclowManagerImpl::SendEnd(u32 task_id) {
return m_mux.SendEnd(task_id);
R_RETURN(m_mux.SendEnd(task_id));
}
Result HtclowManagerImpl::WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) {
return m_mux.WaitReceiveBegin(out_task_id, channel, size);
R_RETURN(m_mux.WaitReceiveBegin(out_task_id, channel, size));
}
Result HtclowManagerImpl::WaitReceiveEnd(u32 task_id) {
return m_mux.WaitReceiveEnd(task_id);
R_RETURN(m_mux.WaitReceiveEnd(task_id));
}
void HtclowManagerImpl::SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config) {
@ -202,7 +202,7 @@ namespace ams::htclow {
}
Result HtclowManagerImpl::Shutdown(impl::ChannelInternalType channel) {
return m_mux.Shutdown(channel);
R_RETURN(m_mux.Shutdown(channel));
}
}

View file

@ -68,7 +68,7 @@ namespace ams::htclow::mux {
/* Process for the channel. */
if (auto it = m_channel_impl_map.GetMap().find(header.channel); it != m_channel_impl_map.GetMap().end()) {
return m_channel_impl_map[it->second].ProcessReceivePacket(header, body, body_size);
R_RETURN(m_channel_impl_map[it->second].ProcessReceivePacket(header, body, body_size));
} else {
if (header.packet_type == PacketType_Data || header.packet_type == PacketType_MaxData) {
this->SendErrorPacket(header.channel);
@ -209,7 +209,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the connection. */
return m_channel_impl_map[it->second].DoConnectBegin(out_task_id);
R_RETURN(m_channel_impl_map[it->second].DoConnectBegin(out_task_id));
}
Result Mux::ConnectEnd(impl::ChannelInternalType channel, u32 task_id) {
@ -230,7 +230,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the disconnection. */
return m_channel_impl_map[it->second].DoConnectEnd();
R_RETURN(m_channel_impl_map[it->second].DoConnectEnd());
}
ChannelState Mux::GetChannelState(impl::ChannelInternalType channel) {
@ -256,7 +256,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the connection. */
return m_channel_impl_map[it->second].DoFlush(out_task_id);
R_RETURN(m_channel_impl_map[it->second].DoFlush(out_task_id));
}
Result Mux::FlushEnd(u32 task_id) {
@ -291,7 +291,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the connection. */
return m_channel_impl_map[it->second].DoReceiveBegin(out_task_id, size);
R_RETURN(m_channel_impl_map[it->second].DoReceiveBegin(out_task_id, size));
}
Result Mux::ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id) {
@ -308,7 +308,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the receive. */
return m_channel_impl_map[it->second].DoReceiveEnd(out, dst, dst_size);
R_RETURN(m_channel_impl_map[it->second].DoReceiveEnd(out, dst, dst_size));
} else {
*out = 0;
R_SUCCEED();
@ -324,7 +324,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the connection. */
return m_channel_impl_map[it->second].DoSend(out_task_id, out, src, src_size);
R_RETURN(m_channel_impl_map[it->second].DoSend(out_task_id, out, src, src_size));
}
Result Mux::SendEnd(u32 task_id) {
@ -344,7 +344,7 @@ namespace ams::htclow::mux {
}
Result Mux::WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size) {
return this->ReceiveBegin(out_task_id, channel, size);
R_RETURN(this->ReceiveBegin(out_task_id, channel, size));
}
Result Mux::WaitReceiveEnd(u32 task_id) {
@ -420,7 +420,7 @@ namespace ams::htclow::mux {
R_UNLESS(it != m_channel_impl_map.GetMap().end(), htclow::ResultChannelNotExist());
/* Perform the shutdown. */
return m_channel_impl_map[it->second].DoShutdown();
R_RETURN(m_channel_impl_map[it->second].DoShutdown());
}
}

View file

@ -67,11 +67,11 @@ namespace ams::htclow::mux {
Result ChannelImpl::ProcessReceivePacket(const PacketHeader &header, const void *body, size_t body_size) {
switch (header.packet_type) {
case PacketType_Data:
return this->ProcessReceiveDataPacket(header.version, header.share, header.offset, body, body_size);
R_RETURN(this->ProcessReceiveDataPacket(header.version, header.share, header.offset, body, body_size));
case PacketType_MaxData:
return this->ProcessReceiveMaxDataPacket(header.version, header.share);
R_RETURN(this->ProcessReceiveMaxDataPacket(header.version, header.share));
case PacketType_Error:
return this->ProcessReceiveErrorPacket();
R_RETURN(this->ProcessReceiveErrorPacket());
default:
R_THROW(htclow::ResultProtocolError());
}