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

@ -170,7 +170,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl {
const int duty = static_cast<int>(((scale * 256.0) / 100.0) + 0.5);
/* Set the duty. */
return this->SetDuty(device, duty);
R_RETURN(this->SetDuty(device, duty));
}
Result PwmDriverImpl::GetScale(double *out, IPwmDevice *device) {
@ -229,7 +229,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl {
});
/* Disable clock to pwm. */
return pcv::SetClockEnabled(pcv::Module_Pwm, false);
R_RETURN(pcv::SetClockEnabled(pcv::Module_Pwm, false));
}
void PwmDriverImpl::Resume() {

View file

@ -62,7 +62,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().SetPeriod(std::addressof(device), period);
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().SetPeriod(std::addressof(device), period));
}
Result ChannelSessionImpl::GetPeriod(TimeSpan *out) {
@ -70,7 +70,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().GetPeriod(out, std::addressof(device));
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().GetPeriod(out, std::addressof(device)));
}
Result ChannelSessionImpl::SetDuty(int duty) {
@ -78,7 +78,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().SetDuty(std::addressof(device), duty);
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().SetDuty(std::addressof(device), duty));
}
Result ChannelSessionImpl::GetDuty(int *out) {
@ -86,7 +86,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().GetDuty(out, std::addressof(device));
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().GetDuty(out, std::addressof(device)));
}
Result ChannelSessionImpl::SetEnabled(bool en) {
@ -94,7 +94,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().SetEnabled(std::addressof(device), en);
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().SetEnabled(std::addressof(device), en));
}
Result ChannelSessionImpl::GetEnabled(bool *out) {
@ -102,7 +102,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().GetEnabled(out, std::addressof(device));
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().GetEnabled(out, std::addressof(device)));
}
Result ChannelSessionImpl::SetScale(double scale) {
@ -110,7 +110,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().SetScale(std::addressof(device), scale);
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().SetScale(std::addressof(device), scale));
}
Result ChannelSessionImpl::GetScale(double *out) {
@ -118,7 +118,7 @@ namespace ams::pwm::driver::impl {
IPwmDevice &device = this->GetDevice().SafeCastTo<IPwmDevice>();
/* Invoke the driver handler. */
return device.GetDriver().SafeCastTo<IPwmDriver>().GetScale(out, std::addressof(device));
R_RETURN(device.GetDriver().SafeCastTo<IPwmDriver>().GetScale(out, std::addressof(device)));
}
}

View file

@ -25,14 +25,10 @@ namespace ams::pwm::driver {
Result OpenSessionImpl(ChannelSession *out, IPwmDevice *device) {
/* Construct the session. */
auto *session = std::construct_at(std::addressof(impl::GetChannelSessionImpl(*out)));
auto session_guard = SCOPE_GUARD { std::destroy_at(session); };
ON_RESULT_FAILURE { std::destroy_at(session); };
/* Open the session. */
R_TRY(session->Open(device, ddsf::AccessMode_ReadWrite));
/* We succeeded. */
session_guard.Cancel();
R_SUCCEED();
R_RETURN(session->Open(device, ddsf::AccessMode_ReadWrite));
}
}

View file

@ -28,7 +28,7 @@ namespace ams::pwm::driver {
}
Result RegisterDeviceCode(DeviceCode device_code, IPwmDevice *device) {
return impl::RegisterDeviceCode(device_code, device);
R_RETURN(impl::RegisterDeviceCode(device_code, device));
}
bool UnregisterDeviceCode(DeviceCode device_code) {

View file

@ -34,7 +34,7 @@ namespace ams::pwm::server {
}
Result ManagerImpl::OpenSession(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name) {
return this->OpenSession2(out, ConvertToDeviceCode(channel_name));
R_RETURN(this->OpenSession2(out, ConvertToDeviceCode(channel_name)));
}
Result ManagerImpl::OpenSession2(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, DeviceCode device_code) {