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

@@ -18,12 +18,12 @@
namespace ams::sf::cmif {
Result DomainServiceObjectDispatchTable::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageImpl(ctx, static_cast<DomainServiceObject *>(ctx.srv_obj)->GetServerDomain(), in_raw_data);
R_RETURN(this->ProcessMessageImpl(ctx, static_cast<DomainServiceObject *>(ctx.srv_obj)->GetServerDomain(), in_raw_data));
}
#if AMS_SF_MITM_SUPPORTED
Result DomainServiceObjectDispatchTable::ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageForMitmImpl(ctx, static_cast<DomainServiceObject *>(ctx.srv_obj)->GetServerDomain(), in_raw_data);
R_RETURN(this->ProcessMessageForMitmImpl(ctx, static_cast<DomainServiceObject *>(ctx.srv_obj)->GetServerDomain(), in_raw_data));
}
#endif
@@ -50,14 +50,14 @@ namespace ams::sf::cmif {
ctx.processor->SetImplementationProcessor(std::addressof(domain_processor));
}
ctx.srv_obj = target_object.GetServiceObjectUnsafe();
return target_object.ProcessMessage(ctx, in_message_raw_data);
R_RETURN(target_object.ProcessMessage(ctx, in_message_raw_data));
}
case CmifDomainRequestType_Close:
/* TODO: N doesn't error check here. Should we? */
domain->UnregisterObject(target_object_id);
R_SUCCEED();
default:
return sf::cmif::ResultInvalidInHeader();
R_THROW(sf::cmif::ResultInvalidInHeader());
}
}
@@ -75,7 +75,7 @@ namespace ams::sf::cmif {
/* Mitm. If we don't have a target object, we should forward to let the server handle. */
if (!target_object) {
return ctx.session->ForwardRequest(ctx);
R_RETURN(ctx.session->ForwardRequest(ctx));
}
R_UNLESS(in_header->data_size + in_header->num_in_objects * sizeof(DomainObjectId) <= in_domain_raw_data.GetSize(), sf::cmif::ResultInvalidHeaderSize());
@@ -90,7 +90,7 @@ namespace ams::sf::cmif {
ctx.processor->SetImplementationProcessor(std::addressof(domain_processor));
}
ctx.srv_obj = target_object.GetServiceObjectUnsafe();
return target_object.ProcessMessage(ctx, in_message_raw_data);
R_RETURN(target_object.ProcessMessage(ctx, in_message_raw_data));
}
case CmifDomainRequestType_Close:
{
@@ -98,7 +98,7 @@ namespace ams::sf::cmif {
/* If the object is not in the domain, tell the server to close it. */
if (!target_object) {
return ctx.session->ForwardRequest(ctx);
R_RETURN(ctx.session->ForwardRequest(ctx));
}
/* If the object is in the domain, close our copy of it. Mitm objects are required to close their associated domain id, so this shouldn't cause desynch. */
@@ -106,7 +106,7 @@ namespace ams::sf::cmif {
R_SUCCEED();
}
default:
return sf::cmif::ResultInvalidInHeader();
R_THROW(sf::cmif::ResultInvalidInHeader());
}
}
#endif
@@ -118,7 +118,7 @@ namespace ams::sf::cmif {
/* Nintendo reserves domain object IDs here. We do this later, to support mitm semantics. */
/* Pass onwards. */
return m_impl_processor->PrepareForProcess(ctx, runtime_metadata);
R_RETURN(m_impl_processor->PrepareForProcess(ctx, runtime_metadata));
}
Result DomainServiceObjectProcessor::GetInObjects(ServiceObjectHolder *in_objects) const {

View File

@@ -105,13 +105,13 @@ namespace ams::sf::cmif {
/* Forward any meta-context change result. */
if (sf::impl::ResultRequestContextChanged::Includes(command_result)) {
return command_result;
R_RETURN(command_result);
}
/* Otherwise, ensure that we're able to write the output header. */
if (out_header == nullptr) {
AMS_ABORT_UNLESS(R_FAILED(command_result));
return command_result;
R_RETURN(command_result);
}
/* Write output header to raw data. */
@@ -138,7 +138,7 @@ namespace ams::sf::cmif {
/* If we didn't find a handler, forward the request. */
if (cmd_handler == nullptr) {
return ctx.session->ForwardRequest(ctx);
R_RETURN(ctx.session->ForwardRequest(ctx));
}
/* Invoke handler. */
@@ -147,18 +147,18 @@ namespace ams::sf::cmif {
/* If we should, forward the request to the forward session. */
if (sm::mitm::ResultShouldForwardToSession::Includes(command_result)) {
return ctx.session->ForwardRequest(ctx);
R_RETURN(ctx.session->ForwardRequest(ctx));
}
/* Forward any meta-context change result. */
if (sf::impl::ResultRequestContextChanged::Includes(command_result)) {
return command_result;
R_RETURN(command_result);
}
/* Otherwise, ensure that we're able to write the output header. */
if (out_header == nullptr) {
AMS_ABORT_UNLESS(R_FAILED(command_result));
return command_result;
R_RETURN(command_result);
}
/* Write output header to raw data. */