ams: use R_DISCARD everywhere

This commit is contained in:
hexkyz
2026-09-23 20:42:15 +01:00
parent 2d0fc65fd8
commit 44d9649c6d
65 changed files with 185 additions and 185 deletions

View File

@@ -274,7 +274,7 @@ namespace ams::ncm {
if (root.content_storage != nullptr) {
/* N doesn't bother checking the result of this. */
root.content_storage->DisableForcibly();
R_DISCARD(root.content_storage->DisableForcibly());
root.content_storage = nullptr;
if (root.storage_id == StorageId::Host) {
@@ -514,7 +514,7 @@ namespace ams::ncm {
if (root.content_meta_database != nullptr) {
/* N doesn't bother checking the result of this. */
root.content_meta_database->DisableForcibly();
R_DISCARD(root.content_meta_database->DisableForcibly());
root.content_meta_database = nullptr;
root.kvs = util::nullopt;
@@ -618,12 +618,12 @@ namespace ams::ncm {
/* Disable and unmount all content storage roots. */
for (size_t i = 0; i < m_num_integrated_content_storage_entries; ++i) {
this->InactivateContentStorage(m_integrated_content_storage_roots[i].m_config->storage_id);
R_DISCARD(this->InactivateContentStorage(m_integrated_content_storage_roots[i].m_config->storage_id));
}
/* Disable and unmount all content meta database roots. */
for (size_t i = 0; i < m_num_integrated_content_meta_entries; ++i) {
this->InactivateContentMetaDatabase(m_integrated_content_meta_database_roots[i].m_config->storage_id);
R_DISCARD(this->InactivateContentMetaDatabase(m_integrated_content_meta_database_roots[i].m_config->storage_id));
}
}
@@ -796,7 +796,7 @@ namespace ams::ncm {
Result ContentManagerImpl::BuildContentMetaDatabaseImpl(StorageId storage_id) {
/* Temporarily activate the database. */
R_TRY(this->ActivateContentMetaDatabase(storage_id));
ON_SCOPE_EXIT { this->InactivateContentMetaDatabase(storage_id); };
ON_SCOPE_EXIT { R_DISCARD(this->InactivateContentMetaDatabase(storage_id)); };
/* Open the content meta database and storage. */
ContentMetaDatabase meta_db;
@@ -848,7 +848,7 @@ namespace ams::ncm {
if (R_FAILED(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem))) {
return true;
}
ON_SCOPE_EXIT { this->InactivateContentMetaDatabase(StorageId::BuiltInSystem); };
ON_SCOPE_EXIT { R_DISCARD(this->InactivateContentMetaDatabase(StorageId::BuiltInSystem)); };
/* Open the content meta db. */
ContentMetaDatabase meta_db;
@@ -976,7 +976,7 @@ namespace ams::ncm {
/* or an empty kvs, both of which we can fix by performing a rebuild. */
if (this->IsNeedRebuildSystemContentMetaDatabase()) {
/* Clean up the system content meta database, to ensure creation can succeed. */
this->CleanupContentMetaDatabase(StorageId::BuiltInSystem);
R_DISCARD(this->CleanupContentMetaDatabase(StorageId::BuiltInSystem));
/* Create the content meta database. */
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
@@ -1005,7 +1005,7 @@ namespace ams::ncm {
/* NOTE: Nintendo does not check this succeeds, and it does on older system versions. */
/* We will not check the error, either, even though this kind of defeats the call's purpose. */
if (hos::GetVersion() >= hos::Version_2_0_0) {
EnsureBuiltInSystemSaveDataFlags();
R_DISCARD(EnsureBuiltInSystemSaveDataFlags());
}
/* Activate the content meta database. */

View File

@@ -510,7 +510,7 @@ namespace ams::ncm {
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), m_root_path);
/* Cleanup the placeholder base directory. */
CleanDirectoryRecursively(placeholder_dir);
R_DISCARD(CleanDirectoryRecursively(placeholder_dir));
R_SUCCEED();
}

View File

@@ -47,7 +47,7 @@ namespace ams::ncm {
void Finalize() {
/* If we're unused and mapped, we should unmap. */
if (!m_is_using && m_is_mapped) {
this->Unmap();
R_DISCARD(this->Unmap());
}
}
private:

View File

@@ -189,7 +189,7 @@ namespace ams::ncm {
/* Cleanup the content meta. */
/* N doesn't check the result of this. */
this->CleanupOne(content_meta);
R_DISCARD(this->CleanupOne(content_meta));
}
/* Cleanup the data and progress. */
@@ -215,7 +215,7 @@ namespace ams::ncm {
/* Delete placeholders for Prepared or Installed content infos. */
if (content_info->install_state == InstallState::Prepared || content_info->install_state == InstallState::Installed) {
content_storage.DeletePlaceHolder(content_info->placeholder_id);
R_DISCARD(content_storage.DeletePlaceHolder(content_info->placeholder_id));
}
}
@@ -344,7 +344,7 @@ namespace ams::ncm {
/* Write all prepared content infos. */
{
/* If we fail while writing, update (but don't check the result). */
ON_RESULT_FAILURE { m_data->Update(content_meta, i); };
ON_RESULT_FAILURE { R_DISCARD(m_data->Update(content_meta, i)); };
/* Create a writer. */
const auto writer = content_meta.GetWriter();
@@ -449,7 +449,7 @@ namespace ams::ncm {
/* Commit the current meta. */
{
/* Ensure that if something goes wrong during commit, we still try to update. */
ON_RESULT_FAILURE { m_data->Update(content_meta, i); };
ON_RESULT_FAILURE { R_DISCARD(m_data->Update(content_meta, i)); };
/* Open a writer. */
const auto writer = content_meta.GetWriter();
@@ -636,7 +636,7 @@ namespace ams::ncm {
/* Update the data (and check result) when we are done. */
{
ON_RESULT_FAILURE { m_data->Update(content_meta, i); };
ON_RESULT_FAILURE { R_DISCARD(m_data->Update(content_meta, i)); };
/* Automatically choose a suitable storage id. */
auto reader = content_meta.GetReader();
@@ -713,7 +713,7 @@ namespace ams::ncm {
/* Create the placeholder. */
R_TRY(storage->CreatePlaceHolder(placeholder_id, meta_info.content_id, meta_info.content_size));
ON_RESULT_FAILURE { storage->DeletePlaceHolder(placeholder_id); };
ON_RESULT_FAILURE { R_DISCARD(storage->DeletePlaceHolder(placeholder_id)); };
/* Output install content info. */
*out_install_content_info = this->MakeInstallContentInfoFrom(meta_info, placeholder_id, is_temporary);
@@ -740,7 +740,7 @@ namespace ams::ncm {
content_storage.GetPlaceHolderPath(std::addressof(path), content_info.GetPlaceHolderId());
/* If we fail, delete the placeholder. */
ON_RESULT_FAILURE { content_storage.DeletePlaceHolder(content_info.GetPlaceHolderId()); };
ON_RESULT_FAILURE { R_DISCARD(content_storage.DeletePlaceHolder(content_info.GetPlaceHolderId())); };
/* Create a new temporary InstallContentInfo if relevant. */
const bool is_temporary = content_info.is_temporary;
@@ -775,7 +775,7 @@ namespace ams::ncm {
/* If the placeholder is temporary, delete it. */
if (is_temporary) {
content_storage.DeletePlaceHolder(content_info.GetPlaceHolderId());
R_DISCARD(content_storage.DeletePlaceHolder(content_info.GetPlaceHolderId()));
}
R_SUCCEED();
@@ -793,7 +793,7 @@ namespace ams::ncm {
reader.ConvertToInstallContentMeta(tmp_buffer.Get(), tmp_buffer.GetSize(), InstallContentInfo::Make(ContentInfo::Make(content_id, size, ContentInfo::DefaultContentAttributes, ContentType::Meta), meta_type));
/* Push the content meta. */
m_data->Push(tmp_buffer.Get(), tmp_buffer.GetSize());
R_DISCARD(m_data->Push(tmp_buffer.Get(), tmp_buffer.GetSize()));
R_SUCCEED();
}
@@ -807,7 +807,7 @@ namespace ams::ncm {
Result InstallTaskBase::PrepareSystemUpdateDependency() {
/* Cleanup on failure. */
ON_RESULT_FAILURE { this->Cleanup(); };
ON_RESULT_FAILURE { R_DISCARD(this->Cleanup()); };
/* Count the number of content meta entries. */
s32 count;
@@ -1066,7 +1066,7 @@ namespace ams::ncm {
void InstallTaskBase::SetLastResult(Result last_result) {
std::scoped_lock lk(m_progress_mutex);
m_data->SetLastResult(last_result);
R_DISCARD(m_data->SetLastResult(last_result));
m_progress.SetLastResult(last_result);
}
@@ -1183,7 +1183,7 @@ namespace ams::ncm {
R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, attr, m_firmware_variation_id));
/* Delete the placeholder. */
content_storage.DeletePlaceHolder(placeholder_id);
R_DISCARD(content_storage.DeletePlaceHolder(placeholder_id));
R_SUCCEED();
}
@@ -1275,7 +1275,7 @@ namespace ams::ncm {
void InstallTaskBase::SetProgressState(InstallProgressState state) {
std::scoped_lock lk(m_progress_mutex);
m_data->SetState(state);
R_DISCARD(m_data->SetState(state));
m_progress.state = state;
}

View File

@@ -357,7 +357,7 @@ namespace ams::ncm {
}
/* NOTE: Nintendo doesn't check that this operation succeeds. */
install_task_data.Push(content_meta.data.get(), content_meta.size);
R_DISCARD(install_task_data.Push(content_meta.data.get(), content_meta.size));
}
/* Change from our current data to the new data. */

View File

@@ -53,7 +53,7 @@ namespace ams::ncm {
/* Remove matching keys. */
for (auto i = 0; i < count.total; i++) {
meta_db.Remove(keys[i]);
R_DISCARD(meta_db.Remove(keys[i]));
}
}
}

View File

@@ -19,14 +19,14 @@ namespace ams::ncm {
PackageSystemUpdateTask::~PackageSystemUpdateTask() {
if (m_context_path.GetLength() > 0) {
fs::DeleteFile(m_context_path);
R_DISCARD(fs::DeleteFile(m_context_path));
}
this->Inactivate();
}
void PackageSystemUpdateTask::Inactivate() {
if (m_gamecard_content_meta_database_active) {
InactivateContentMetaDatabase(StorageId::GameCard);
R_DISCARD(InactivateContentMetaDatabase(StorageId::GameCard));
m_gamecard_content_meta_database_active = false;
}
}
@@ -41,7 +41,7 @@ namespace ams::ncm {
auto meta_db_guard = SCOPE_GUARD { this->Inactivate(); };
/* Open the game card content meta database. */
OpenContentMetaDatabase(std::addressof(m_package_db), StorageId::GameCard);
R_DISCARD(OpenContentMetaDatabase(std::addressof(m_package_db), StorageId::GameCard));
ContentMetaDatabaseBuilder builder(std::addressof(m_package_db));
@@ -50,9 +50,9 @@ namespace ams::ncm {
R_TRY(builder.BuildFromPackage(package_root));
/* Create a new context file. */
fs::DeleteFile(context_path);
R_DISCARD(fs::DeleteFile(context_path));
R_TRY(FileInstallTaskData::Create(context_path, GameCardMaxContentMetaCount));
auto context_guard = SCOPE_GUARD { fs::DeleteFile(context_path); };
auto context_guard = SCOPE_GUARD { R_DISCARD(fs::DeleteFile(context_path)); };
/* Initialize data. */
R_TRY(m_data.Initialize(context_path));

View File

@@ -115,7 +115,7 @@ namespace ams::ncm {
void PlaceHolderAccessor::Invalidate(CacheEntry *entry) {
/* Flush and close the cached entry's file. */
if (entry != nullptr) {
fs::FlushFile(entry->handle);
R_DISCARD(fs::FlushFile(entry->handle));
fs::CloseFile(entry->handle);
entry->id = InvalidPlaceHolderId;
}

View File

@@ -69,7 +69,7 @@ namespace ams::ncm {
R_TRY(m_impl->Initialize());
/* Initialize parent. N doesn't check the result. */
PackageInstallTask::Initialize(impl::GetRootDirectoryPath(m_impl->GetMountName()).str, storage_id, buffer, buffer_size, ignore_ticket);
R_DISCARD(PackageInstallTask::Initialize(impl::GetRootDirectoryPath(m_impl->GetMountName()).str, storage_id, buffer, buffer_size, ignore_ticket));
R_SUCCEED();
}