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

@ -22,29 +22,30 @@ namespace ams::ldr {
public:
/* Official commands. */
Result CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle &&reslimit_h) {
/* Create a handle to set the output to when done. */
os::NativeHandle handle = os::InvalidNativeHandle;
const auto result = this->CreateProcess(std::addressof(handle), id, flags, reslimit_h.GetOsHandle());
proc_h.SetValue(handle, true);
return result;
ON_SCOPE_EXIT { proc_h.SetValue(handle, true); };
R_RETURN(this->CreateProcess(std::addressof(handle), id, flags, reslimit_h.GetOsHandle()));
}
Result GetProgramInfo(sf::Out<ProgramInfo> out_program_info, const ncm::ProgramLocation &loc) {
return this->GetProgramInfo(out_program_info.GetPointer(), nullptr, loc);
R_RETURN(this->GetProgramInfo(out_program_info.GetPointer(), nullptr, loc));
}
Result PinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc) {
return this->PinProgram(out_id.GetPointer(), loc, cfg::OverrideStatus{});
R_RETURN(this->PinProgram(out_id.GetPointer(), loc, cfg::OverrideStatus{}));
}
Result UnpinProgram(PinId id);
Result SetProgramArgumentDeprecated(ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size) {
AMS_UNUSED(args_size);
return this->SetProgramArgument(program_id, args.GetPointer(), std::min<size_t>(args_size, args.GetSize()));
R_RETURN(this->SetProgramArgument(program_id, args.GetPointer(), std::min<size_t>(args_size, args.GetSize())));
}
Result SetProgramArgument(ncm::ProgramId program_id, const sf::InPointerBuffer &args) {
return this->SetProgramArgument(program_id, args.GetPointer(), args.GetSize());
R_RETURN(this->SetProgramArgument(program_id, args.GetPointer(), args.GetSize()));
}
Result FlushArguments();
@ -52,17 +53,18 @@ namespace ams::ldr {
Result GetProcessModuleInfo(sf::Out<u32> count, const sf::OutPointerArray<ModuleInfo> &out, os::ProcessId process_id) {
R_UNLESS(out.GetSize() <= std::numeric_limits<s32>::max(), ldr::ResultInvalidSize());
return this->GetProcessModuleInfo(count.GetPointer(), out.GetPointer(), out.GetSize(), process_id);
R_RETURN(this->GetProcessModuleInfo(count.GetPointer(), out.GetPointer(), out.GetSize(), process_id));
}
Result SetEnabledProgramVerification(bool enabled);
/* Atmosphere commands. */
Result AtmosphereRegisterExternalCode(sf::OutMoveHandle out, ncm::ProgramId program_id) {
/* Create a handle to set the output to when done. */
os::NativeHandle handle = os::InvalidNativeHandle;
const auto result = this->RegisterExternalCode(std::addressof(handle), program_id);
out.SetValue(handle, true);
return result;
ON_SCOPE_EXIT { out.SetValue(handle, true); };
R_RETURN(this->RegisterExternalCode(std::addressof(handle), program_id));
}
void AtmosphereUnregisterExternalCode(ncm::ProgramId program_id) {
@ -74,11 +76,11 @@ namespace ams::ldr {
}
Result AtmosphereGetProgramInfo(sf::Out<ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc) {
return this->GetProgramInfo(out_program_info.GetPointer(), out_status.GetPointer(), loc);
R_RETURN(this->GetProgramInfo(out_program_info.GetPointer(), out_status.GetPointer(), loc));
}
Result AtmospherePinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status) {
return this->PinProgram(out_id.GetPointer(), loc, override_status);
R_RETURN(this->PinProgram(out_id.GetPointer(), loc, override_status));
}
private:
Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit);