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

@@ -70,7 +70,7 @@ namespace ams::mitm::sysupdater {
}
Result AsyncPrepareSdCardUpdateImpl::Execute() {
return m_task->PrepareAndExecute();
R_RETURN(m_task->PrepareAndExecute());
}
void AsyncPrepareSdCardUpdateImpl::CancelImpl() {

View File

@@ -29,28 +29,21 @@ namespace ams::mitm::sysupdater {
template<typename T>
Result SaveErrorContextIfFailed(T &async, Result result) {
if (R_FAILED(result)) {
async.GetErrorContext(std::addressof(m_error_context));
return result;
}
ON_RESULT_FAILURE { async.GetErrorContext(std::addressof(m_error_context)); };
R_SUCCEED();
R_RETURN(result);
}
template<typename T>
Result GetAndSaveErrorContext(T &async) {
R_TRY(this->SaveErrorContextIfFailed(async, async.Get()));
R_SUCCEED();
R_RETURN(this->SaveErrorContextIfFailed(async, async.Get()));
}
template<typename T>
Result SaveInternalTaskErrorContextIfFailed(T &async, Result result) {
if (R_FAILED(result)) {
async.CreateErrorContext(std::addressof(m_error_context));
return result;
}
ON_RESULT_FAILURE { async.CreateErrorContext(std::addressof(m_error_context)); };
R_SUCCEED();
R_RETURN(result);
}
const err::ErrorContext &GetErrorContextImpl() {
@@ -82,7 +75,7 @@ namespace ams::mitm::sysupdater {
virtual ~AsyncResultBase() { /* ... */ }
Result Get() {
return ToAsyncResult(this->GetImpl());
R_RETURN(ToAsyncResult(this->GetImpl()));
}
private:
virtual Result GetImpl() = 0;

View File

@@ -208,8 +208,8 @@ namespace ams::mitm::sysupdater {
/* Open the appropriate interface. */
const auto * const creator_intfs = fssystem::GetFileSystemCreatorInterfaces();
switch (fs_type) {
case fssystem::NcaFsHeader::FsType::PartitionFs: return creator_intfs->partition_fs_creator->Create(out, std::move(storage));
case fssystem::NcaFsHeader::FsType::RomFs: return creator_intfs->rom_fs_creator->Create(out, std::move(storage));
case fssystem::NcaFsHeader::FsType::PartitionFs: R_RETURN(creator_intfs->partition_fs_creator->Create(out, std::move(storage)));
case fssystem::NcaFsHeader::FsType::RomFs: R_RETURN(creator_intfs->rom_fs_creator->Create(out, std::move(storage)));
default:
R_THROW(fs::ResultInvalidNcaFileSystemType());
}
@@ -248,7 +248,7 @@ namespace ams::mitm::sysupdater {
R_UNLESS(unique_fs != nullptr, fs::ResultAllocationMemoryFailedNew());
/* Register the fs. */
return ams::fs::fsa::Register(mount_name, std::move(unique_fs));
R_RETURN(ams::fs::fsa::Register(mount_name, std::move(unique_fs)));
}
}

View File

@@ -60,7 +60,7 @@ namespace ams::mitm::sysupdater {
const size_t path_len = util::SNPrintf(package_path, sizeof(package_path), "%s%s", package_root_path, entry_path);
AMS_ABORT_UNLESS(path_len < ams::fs::EntryNameLengthMax);
return ams::fs::ConvertToFsCommonPath(dst, dst_size, package_path);
R_RETURN(ams::fs::ConvertToFsCommonPath(dst, dst_size, package_path));
}
Result LoadContentMeta(ncm::AutoBuffer *out, const char *package_root_path, const fs::DirectoryEntry &entry) {
@@ -69,7 +69,7 @@ namespace ams::mitm::sysupdater {
char path[ams::fs::EntryNameLengthMax];
R_TRY(ConvertToFsCommonPath(path, sizeof(path), package_root_path, entry.name));
return ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path);
R_RETURN(ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path));
}
Result ReadContentMetaPath(ncm::AutoBuffer *out, const char *package_root, const ncm::ContentInfo &content_info) {
@@ -84,7 +84,7 @@ namespace ams::mitm::sysupdater {
R_TRY(ConvertToFsCommonPath(content_path.str, sizeof(content_path.str), package_root, cnmt_nca_name));
/* Read the content meta path. */
return ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, content_path.str);
R_RETURN(ncm::ReadContentMetaPathAlongWithExtendedDataAndDigest(out, content_path.str));
}
Result GetSystemUpdateUpdateContentInfoFromPackage(ncm::ContentInfo *out, const char *package_root) {
@@ -154,7 +154,7 @@ namespace ams::mitm::sysupdater {
/* Declare helper for result validation. */
auto ValidateResult = [&](Result result) ALWAYS_INLINE_LAMBDA -> Result {
*out_result = result;
return result;
R_RETURN(result);
};
/* Iterate over all files to find all content metas. */
@@ -411,11 +411,11 @@ namespace ams::mitm::sysupdater {
};
Result SystemUpdateService::SetupUpdate(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) {
return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, GetFirmwareVariationId());
R_RETURN(this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, GetFirmwareVariationId()));
}
Result SystemUpdateService::SetupUpdateWithVariation(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) {
return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id);
R_RETURN(this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id));
}
Result SystemUpdateService::RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out<sf::SharedPointer<ns::impl::IAsyncResult>> out_async) {