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

@@ -95,13 +95,13 @@ namespace ams::sf::cmif {
template<typename T>
Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
static_assert(std::is_base_of<ServiceDispatchTableBase, T>::value, "ServiceDispatchTableBase::Process<T>");
return static_cast<const T *>(this)->ProcessMessage(ctx, in_raw_data);
R_RETURN(static_cast<const T *>(this)->ProcessMessage(ctx, in_raw_data));
}
template<typename T>
Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
static_assert(std::is_base_of<ServiceDispatchTableBase, T>::value, "ServiceDispatchTableBase::ProcessForMitm<T>");
return static_cast<const T *>(this)->ProcessMessageForMitm(ctx, in_raw_data);
R_RETURN(static_cast<const T *>(this)->ProcessMessageForMitm(ctx, in_raw_data));
}
};
@@ -115,11 +115,11 @@ namespace ams::sf::cmif {
explicit constexpr ServiceDispatchTableImpl(const std::array<ServiceCommandMeta, N> &e) : m_entries{e} { /* ... */ }
Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug);
R_RETURN(this->ProcessMessageImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug));
}
Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageForMitmImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug);
R_RETURN(this->ProcessMessageForMitmImpl(ctx, in_raw_data, m_entries.data(), m_entries.size(), InterfaceIdForDebug));
}
constexpr const std::array<ServiceCommandMeta, N> &GetEntries() const {

View File

@@ -190,14 +190,14 @@ namespace ams::sf::hipc {
template<typename Interface>
Result AcceptImpl(Server *server, SharedPointer<Interface> p) {
return ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p));
R_RETURN(ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p)));
}
#if AMS_SF_MITM_SUPPORTED
template<typename Interface>
Result AcceptMitmImpl(Server *server, SharedPointer<Interface> p, std::shared_ptr<::Service> forward_service) {
AMS_ABORT_UNLESS(this->CanManageMitmServers());
return ServerSessionManager::AcceptMitmSession(server->m_port_handle, std::move(p), std::move(forward_service));
R_RETURN(ServerSessionManager::AcceptMitmSession(server->m_port_handle, std::move(p), std::move(forward_service)));
}
template<typename Interface>
@@ -269,7 +269,7 @@ namespace ams::sf::hipc {
template<typename Interface>
Result RegisterObjectForServer(SharedPointer<Interface> static_object, sm::ServiceName service_name, size_t max_sessions) {
return this->RegisterServerImpl(0, cmif::ServiceObjectHolder(std::move(static_object)), service_name, max_sessions);
R_RETURN(this->RegisterServerImpl(0, cmif::ServiceObjectHolder(std::move(static_object)), service_name, max_sessions));
}
void RegisterServer(int port_index, os::NativeHandle port_handle) {
@@ -277,7 +277,7 @@ namespace ams::sf::hipc {
}
Result RegisterServer(int port_index, sm::ServiceName service_name, size_t max_sessions) {
return this->RegisterServerImpl(port_index, cmif::ServiceObjectHolder(), service_name, max_sessions);
R_RETURN(this->RegisterServerImpl(port_index, cmif::ServiceObjectHolder(), service_name, max_sessions));
}
/* Processing. */
@@ -503,7 +503,7 @@ namespace ams::sf::hipc {
template<typename Interface, bool Enable = ManagerOptions::CanManageMitmServers, typename = typename std::enable_if<Enable>::type>
Result RegisterMitmServer(int port_index, sm::ServiceName service_name) {
AMS_ABORT_UNLESS(this->CanManageMitmServers());
return this->template RegisterMitmServerImpl<Interface>(port_index, cmif::ServiceObjectHolder(), service_name);
R_RETURN(this->template RegisterMitmServerImpl<Interface>(port_index, cmif::ServiceObjectHolder(), service_name));
}
#endif
};

View File

@@ -140,36 +140,36 @@ namespace ams::sf::hipc {
#endif
Result ReceiveRequest(ServerSession *session, const cmif::PointerAndSize &message) {
return this->ReceiveRequestImpl(session, message);
R_RETURN(this->ReceiveRequestImpl(session, message));
}
Result RegisterSession(ServerSession **out, os::NativeHandle session_handle, cmif::ServiceObjectHolder &&obj) {
auto ctor = [&](ServerSession *session_memory) -> Result {
return this->RegisterSessionImpl(session_memory, session_handle, std::forward<cmif::ServiceObjectHolder>(obj));
R_RETURN(this->RegisterSessionImpl(session_memory, session_handle, std::forward<cmif::ServiceObjectHolder>(obj)));
};
return this->CreateSessionImpl(out, ctor);
R_RETURN(this->CreateSessionImpl(out, ctor));
}
Result AcceptSession(ServerSession **out, os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) {
auto ctor = [&](ServerSession *session_memory) -> Result {
return this->AcceptSessionImpl(session_memory, port_handle, std::forward<cmif::ServiceObjectHolder>(obj));
R_RETURN(this->AcceptSessionImpl(session_memory, port_handle, std::forward<cmif::ServiceObjectHolder>(obj)));
};
return this->CreateSessionImpl(out, ctor);
R_RETURN(this->CreateSessionImpl(out, ctor));
}
#if AMS_SF_MITM_SUPPORTED
Result RegisterMitmSession(ServerSession **out, os::NativeHandle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
auto ctor = [&](ServerSession *session_memory) -> Result {
return this->RegisterMitmSessionImpl(session_memory, mitm_session_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
R_RETURN(this->RegisterMitmSessionImpl(session_memory, mitm_session_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv)));
};
return this->CreateSessionImpl(out, ctor);
R_RETURN(this->CreateSessionImpl(out, ctor));
}
Result AcceptMitmSession(ServerSession **out, os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
auto ctor = [&](ServerSession *session_memory) -> Result {
return this->AcceptMitmSessionImpl(session_memory, mitm_port_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
R_RETURN(this->AcceptMitmSessionImpl(session_memory, mitm_port_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv)));
};
return this->CreateSessionImpl(out, ctor);
R_RETURN(this->CreateSessionImpl(out, ctor));
}
#endif
public:
@@ -183,13 +183,13 @@ namespace ams::sf::hipc {
template<typename Interface>
Result AcceptSession(os::NativeHandle port_handle, SharedPointer<Interface> obj) {
return this->AcceptSession(port_handle, cmif::ServiceObjectHolder(std::move(obj)));
R_RETURN(this->AcceptSession(port_handle, cmif::ServiceObjectHolder(std::move(obj))));
}
#if AMS_SF_MITM_SUPPORTED
template<typename Interface>
Result AcceptMitmSession(os::NativeHandle mitm_port_handle, SharedPointer<Interface> obj, std::shared_ptr<::Service> &&fsrv) {
return this->AcceptMitmSession(mitm_port_handle, cmif::ServiceObjectHolder(std::move(obj)), std::forward<std::shared_ptr<::Service>>(fsrv));
R_RETURN(this->AcceptMitmSession(mitm_port_handle, cmif::ServiceObjectHolder(std::move(obj)), std::forward<std::shared_ptr<::Service>>(fsrv)));
}
#endif

View File

@@ -1197,7 +1197,7 @@ namespace ams::sf::impl {
sf::IServiceObject * const this_ptr = ctx.srv_obj;
command_result = [this_ptr, invoke_impl, &args_tuple]<size_t ...Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
return invoke_impl(this_ptr, std::forward<typename std::tuple_element<Ix, TrueArgumentsTuple>::type>(std::get<Ix>(args_tuple))...);
R_RETURN(invoke_impl(this_ptr, std::forward<typename std::tuple_element<Ix, TrueArgumentsTuple>::type>(std::get<Ix>(args_tuple))...));
}(std::make_index_sequence<std::tuple_size<typename CommandMeta::ArgsTypeForInvoke>::value>());
}
@@ -1205,7 +1205,7 @@ namespace ams::sf::impl {
cmif::PointerAndSize out_raw_data;
ctx.processor->PrepareForErrorReply(ctx, out_raw_data, runtime_metadata);
R_TRY(GetCmifOutHeaderPointer(out_header_ptr, out_raw_data));
return command_result;
R_RETURN(command_result);
}
}
@@ -1254,14 +1254,14 @@ namespace ams::sf::impl {
constexpr bool ReturnsVoid = std::is_same<Return, void>::value;
static_assert(ReturnsResult || ReturnsVoid, "Service Commands must return Result or void.");
return InvokeServiceCommandImplCommon<CommandMeta, Arguments...>(out_header_ptr, ctx, in_raw_data, +[](sf::IServiceObject *srv_obj, Arguments &&... args) -> Result {
R_RETURN((InvokeServiceCommandImplCommon<CommandMeta, Arguments...>(out_header_ptr, ctx, in_raw_data, +[](sf::IServiceObject *srv_obj, Arguments &&... args) -> Result {
if constexpr (ReturnsResult) {
return (static_cast<ClassType *>(srv_obj)->*ServiceCommandImpl)(std::forward<Arguments>(args)...);
R_RETURN((static_cast<ClassType *>(srv_obj)->*ServiceCommandImpl)(std::forward<Arguments>(args)...));
} else {
(static_cast<ClassType *>(srv_obj)->*ServiceCommandImpl)(std::forward<Arguments>(args)...);
R_SUCCEED();
}
});
})));
}
}