diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp index 3b866be8e..78711d0e1 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp @@ -262,8 +262,8 @@ namespace ams::kern::arch::arm64 { R_UNLESS(entry.handler != nullptr, svc::ResultInvalidState()); /* If auto-cleared, we can succeed immediately. */ - R_UNLESS(entry.manually_cleared, ResultSuccess()); - R_UNLESS(entry.needs_clear, ResultSuccess()); + R_SUCCEED_IF(!entry.manually_cleared); + R_SUCCEED_IF(!entry.needs_clear); /* Clear and enable. */ entry.needs_clear = false; @@ -277,8 +277,8 @@ namespace ams::kern::arch::arm64 { R_UNLESS(entry.handler != nullptr, svc::ResultInvalidState()); /* If auto-cleared, we can succeed immediately. */ - R_UNLESS(entry.manually_cleared, ResultSuccess()); - R_UNLESS(entry.needs_clear, ResultSuccess()); + R_SUCCEED_IF(!entry.manually_cleared); + R_SUCCEED_IF(!entry.needs_clear); /* Clear and set priority. */ entry.needs_clear = false; diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp index db1c1e27b..9429ef854 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp @@ -832,7 +832,7 @@ namespace ams::kern::arch::arm64 { L1PageTableEntry *l1_entry = impl.GetL1Entry(virt_addr); if (l1_entry->IsBlock()) { /* If our block size is too big, don't bother. */ - R_UNLESS(block_size < L1BlockSize, ResultSuccess()); + R_SUCCEED_IF(block_size >= L1BlockSize); /* Get the addresses we're working with. */ const KProcessAddress block_virt_addr = util::AlignDown(GetInteger(virt_addr), L1BlockSize); @@ -859,10 +859,10 @@ namespace ams::kern::arch::arm64 { } /* If we don't have an l1 table, we're done. */ - R_UNLESS(l1_entry->IsTable(), ResultSuccess()); + R_SUCCEED_IF(!l1_entry->IsTable()); /* We want to separate L2 contiguous blocks into L2 blocks, so check that our size permits that. */ - R_UNLESS(block_size < L2ContiguousBlockSize, ResultSuccess()); + R_SUCCEED_IF(block_size >= L2ContiguousBlockSize); L2PageTableEntry *l2_entry = impl.GetL2Entry(l1_entry, virt_addr); if (l2_entry->IsBlock()) { @@ -878,7 +878,7 @@ namespace ams::kern::arch::arm64 { } /* We want to separate L2 blocks into L3 contiguous blocks, so check that our size permits that. */ - R_UNLESS(block_size < L2BlockSize, ResultSuccess()); + R_SUCCEED_IF(block_size >= L2BlockSize); /* Get the addresses we're working with. */ const KProcessAddress block_virt_addr = util::AlignDown(GetInteger(virt_addr), L2BlockSize); @@ -905,10 +905,10 @@ namespace ams::kern::arch::arm64 { } /* If we don't have an L3 table, we're done. */ - R_UNLESS(l2_entry->IsTable(), ResultSuccess()); + R_SUCCEED_IF(!l2_entry->IsTable()); /* We want to separate L3 contiguous blocks into L2 blocks, so check that our size permits that. */ - R_UNLESS(block_size < L3ContiguousBlockSize, ResultSuccess()); + R_SUCCEED_IF(block_size >= L3ContiguousBlockSize); /* If we're contiguous, try to separate. */ L3PageTableEntry *l3_entry = impl.GetL3Entry(l2_entry, virt_addr); diff --git a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp index 874d234f7..28eb097d3 100644 --- a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp +++ b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp @@ -257,7 +257,7 @@ namespace ams::kern::board::nintendo::nx { const WordType clear_bit = (this->state[i] + 1) ^ (this->state[i]); this->state[i] |= clear_bit; out[num_reserved++] = static_cast(BitsPerWord * i + BitsPerWord - 1 - ClearLeadingZero(clear_bit)); - R_UNLESS(num_reserved != num_desired, ResultSuccess()); + R_SUCCEED_IF(num_reserved == num_desired); } } diff --git a/libraries/libmesosphere/source/kern_k_capabilities.cpp b/libraries/libmesosphere/source/kern_k_capabilities.cpp index 5e9b36356..871721108 100644 --- a/libraries/libmesosphere/source/kern_k_capabilities.cpp +++ b/libraries/libmesosphere/source/kern_k_capabilities.cpp @@ -211,7 +211,9 @@ namespace ams::kern { /* Validate this is a capability we can act on. */ const auto type = GetCapabilityType(cap); R_UNLESS(type != CapabilityType::Invalid, svc::ResultInvalidArgument()); - R_UNLESS(type != CapabilityType::Padding, ResultSuccess()); + + /* If the type is padding, we have no work to do. */ + R_SUCCEED_IF(type == CapabilityType::Padding); /* Check that we haven't already processed this capability. */ const auto flag = GetCapabilityFlag(type); diff --git a/libraries/libmesosphere/source/kern_k_page_group.cpp b/libraries/libmesosphere/source/kern_k_page_group.cpp index 3e81eb593..1340064c9 100644 --- a/libraries/libmesosphere/source/kern_k_page_group.cpp +++ b/libraries/libmesosphere/source/kern_k_page_group.cpp @@ -38,7 +38,7 @@ namespace ams::kern { Result KPageGroup::AddBlock(KVirtualAddress addr, size_t num_pages) { /* Succeed immediately if we're adding no pages. */ - R_UNLESS(num_pages != 0, ResultSuccess()); + R_SUCCEED_IF(num_pages == 0); /* Check for overflow. */ MESOSPHERE_ASSERT(addr < addr + num_pages * PageSize); @@ -46,7 +46,7 @@ namespace ams::kern { /* Try to just append to the last block. */ if (!this->block_list.empty()) { auto it = --(this->block_list.end()); - R_UNLESS(!it->TryConcatenate(addr, num_pages), ResultSuccess()); + R_SUCCEED_IF(it->TryConcatenate(addr, num_pages)); } /* Allocate a new block. */ diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp index 60529972e..c2424cf3c 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp @@ -28,17 +28,27 @@ namespace ams::fs { MemoryStorage(void *b, s64 sz) : buf(static_cast(b)), size(sz) { /* .. */ } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { - R_UNLESS(size != 0, ResultSuccess()); + /* Succeed immediately on zero-sized read. */ + R_SUCCEED_IF(size == 0); + + /* Validate arguments. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(IStorage::IsRangeValid(offset, size, this->size), fs::ResultOutOfRange()); + + /* Copy from memory. */ std::memcpy(buffer, this->buf + offset, size); return ResultSuccess(); } - virtual Result Write(s64 offset, const void *buffer, size_t size) override{ - R_UNLESS(size != 0, ResultSuccess()); + virtual Result Write(s64 offset, const void *buffer, size_t size) override { + /* Succeed immediately on zero-sized write. */ + R_SUCCEED_IF(size == 0); + + /* Validate arguments. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(IStorage::IsRangeValid(offset, size, this->size), fs::ResultOutOfRange()); + + /* Copy to memory. */ std::memcpy(this->buf + offset, buffer, size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp index 1bcebd337..be0e15778 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp @@ -69,16 +69,27 @@ namespace ams::fs { } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { + /* Ensure we're initialized. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - R_UNLESS(size != 0, ResultSuccess()); + + /* Succeed immediately on zero-sized operation. */ + R_SUCCEED_IF(size == 0); + + + /* Validate arguments and read. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(IStorage::IsRangeValid(offset, size, this->size), fs::ResultOutOfRange()); return this->base_storage->Read(this->offset + offset, buffer, size); } virtual Result Write(s64 offset, const void *buffer, size_t size) override{ + /* Ensure we're initialized. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - R_UNLESS(size != 0, ResultSuccess()); + + /* Succeed immediately on zero-sized operation. */ + R_SUCCEED_IF(size == 0); + + /* Validate arguments and write. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(IStorage::IsRangeValid(offset, size, this->size), fs::ResultOutOfRange()); return this->base_storage->Write(this->offset + offset, buffer, size); @@ -90,15 +101,17 @@ namespace ams::fs { } virtual Result SetSize(s64 size) override { + /* Ensure we're initialized and validate arguments. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); R_UNLESS(this->resizable, fs::ResultUnsupportedOperation()); R_UNLESS(IStorage::IsOffsetAndSizeValid(this->offset, size), fs::ResultInvalidSize()); + /* Ensure that we're allowed to set size. */ s64 cur_size; R_TRY(this->base_storage->GetSize(std::addressof(cur_size))); - R_UNLESS(cur_size == this->offset + this->size, fs::ResultUnsupportedOperation()); + /* Set the size. */ R_TRY(this->base_storage->SetSize(this->offset + size)); this->size = size; @@ -106,14 +119,21 @@ namespace ams::fs { } virtual Result GetSize(s64 *out) override { + /* Ensure we're initialized. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); + *out = this->size; return ResultSuccess(); } virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { + /* Ensure we're initialized. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - R_UNLESS(size != 0, ResultSuccess()); + + /* Succeed immediately on zero-sized operation. */ + R_SUCCEED_IF(size == 0); + + /* Validate arguments and operate. */ R_UNLESS(IStorage::IsOffsetAndSizeValid(offset, size), fs::ResultOutOfRange()); return this->base_storage->OperateRange(dst, dst_size, op_id, this->offset + offset, size, src, src_size); } diff --git a/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp b/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp index 7b1ca0bc3..e73e66713 100644 --- a/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp @@ -65,7 +65,7 @@ namespace ams::spl { constexpr inline ::ams::Result ConvertResult(Result smc_result) { /* smc::Result::Success becomes ResultSuccess() directly. */ - R_UNLESS(smc_result != Result::Success, ResultSuccess()); + R_SUCCEED_IF(smc_result == smc::Result::Success); /* Convert to the list of known SecureMonitorErrors. */ const auto converted = R_MAKE_NAMESPACE_RESULT(::ams::spl, static_cast(smc_result)); diff --git a/libraries/libstratosphere/source/fs/fs_file_storage.cpp b/libraries/libstratosphere/source/fs/fs_file_storage.cpp index f6f510286..d96f723c1 100644 --- a/libraries/libstratosphere/source/fs/fs_file_storage.cpp +++ b/libraries/libstratosphere/source/fs/fs_file_storage.cpp @@ -18,13 +18,13 @@ namespace ams::fs { Result FileStorage::UpdateSize() { - R_UNLESS(this->size == InvalidSize, ResultSuccess()); + R_SUCCEED_IF(this->size != InvalidSize); return this->base_file->GetSize(&this->size); } Result FileStorage::Read(s64 offset, void *buffer, size_t size) { /* Immediately succeed if there's nothing to read. */ - R_UNLESS(size > 0, ResultSuccess()); + R_SUCCEED_IF(size == 0); /* Validate buffer. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); @@ -41,7 +41,7 @@ namespace ams::fs { Result FileStorage::Write(s64 offset, const void *buffer, size_t size) { /* Immediately succeed if there's nothing to write. */ - R_UNLESS(size > 0, ResultSuccess()); + R_SUCCEED_IF(size == 0); /* Validate buffer. */ R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); diff --git a/libraries/libstratosphere/source/fs/fs_path_utils.cpp b/libraries/libstratosphere/source/fs/fs_path_utils.cpp index 5b60e2732..db15d5b8f 100644 --- a/libraries/libstratosphere/source/fs/fs_path_utils.cpp +++ b/libraries/libstratosphere/source/fs/fs_path_utils.cpp @@ -25,7 +25,7 @@ namespace ams::fs { const char c = *(cur++); /* If terminated, we're done. */ - R_UNLESS(c != StringTraits::NullTerminator, ResultSuccess()); + R_SUCCEED_IF(PathTool::IsNullTerminator(c)); /* TODO: Nintendo converts the path from utf-8 to utf-32, one character at a time. */ /* We should do this. */ diff --git a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index 9cc3d15db..f867917cc 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -178,7 +178,7 @@ namespace ams::fssystem { Result DirectorySaveDataFileSystem::CopySaveFromFileSystem(fs::fsa::IFileSystem *save_fs) { /* If the input save is null, there's nothing to copy. */ - R_UNLESS(save_fs != nullptr, ResultSuccess()); + R_SUCCEED_IF(save_fs == nullptr); /* Get a work buffer to work with. */ std::unique_ptr work_buf; diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp index 64ca4e920..46c58f90a 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp @@ -30,7 +30,7 @@ namespace ams::lr { Result ContentLocationResolverImpl::ResolveProgramPath(sf::Out out, ncm::ProgramId id) { /* Use a redirection if present. */ - R_UNLESS(!this->program_redirector.FindRedirection(out.GetPointer(), id), ResultSuccess()); + R_SUCCEED_IF(this->program_redirector.FindRedirection(out.GetPointer(), id)); /* Find the latest program content for the program id. */ ncm::ContentId program_content_id; @@ -164,7 +164,7 @@ namespace ams::lr { Result ContentLocationResolverImpl::ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) { /* Use a redirection if present. */ - R_UNLESS(!this->debug_program_redirector.FindRedirection(out.GetPointer(), id), ResultSuccess()); + R_SUCCEED_IF(this->debug_program_redirector.FindRedirection(out.GetPointer(), id)); /* Otherwise find the path for the program id. */ R_TRY_CATCH(this->ResolveProgramPath(out.GetPointer(), id)) { diff --git a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp index 7d2c55511..5874cc2bb 100644 --- a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp @@ -128,13 +128,11 @@ namespace ams::lr { } Result RedirectOnlyLocationResolverImpl::ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) { - /* Use a redirection if present. */ - R_UNLESS(!this->debug_program_redirector.FindRedirection(out.GetPointer(), id), ResultSuccess()); + /* If a debug program redirection is present, use it. */ + R_SUCCEED_IF(this->debug_program_redirector.FindRedirection(out.GetPointer(), id)); - /* Otherwise find the path for the program id. */ - R_TRY_CATCH(this->ResolveProgramPath(out.GetPointer(), id)) { - R_CONVERT(ResultProgramNotFound, lr::ResultDebugProgramNotFound()) - } R_END_TRY_CATCH; + /* Otherwise, try to find a normal program redirection. */ + R_UNLESS(this->program_redirector.FindRedirection(out.GetPointer(), id), lr::ResultDebugProgramNotFound()); return ResultSuccess(); } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp index ce3e4da42..8594045e9 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp @@ -98,7 +98,7 @@ namespace ams::mitm::fs { Result LayeredRomfsStorage::Read(s64 offset, void *buffer, size_t size) { /* Check if we can succeed immediately. */ R_UNLESS(size >= 0, fs::ResultInvalidSize()); - R_UNLESS(size > 0, ResultSuccess()); + R_SUCCEED_IF(size == 0); /* Ensure we're initialized. */ if (!this->is_initialized) { diff --git a/stratosphere/boot/source/boot_i2c_utils.cpp b/stratosphere/boot/source/boot_i2c_utils.cpp index 47185d438..8d5a8f9a5 100644 --- a/stratosphere/boot/source/boot_i2c_utils.cpp +++ b/stratosphere/boot/source/boot_i2c_utils.cpp @@ -27,7 +27,7 @@ namespace ams::boot { u64 cur_time = 0; while (true) { const auto retry_result = f(); - R_UNLESS(R_FAILED(retry_result), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(retry_result)); cur_time += retry_interval; if (cur_time < timeout) { diff --git a/stratosphere/boot/source/i2c/driver/impl/i2c_bus_accessor.cpp b/stratosphere/boot/source/i2c/driver/impl/i2c_bus_accessor.cpp index 16c53a487..78bd68e31 100644 --- a/stratosphere/boot/source/i2c/driver/impl/i2c_bus_accessor.cpp +++ b/stratosphere/boot/source/i2c/driver/impl/i2c_bus_accessor.cpp @@ -379,7 +379,8 @@ namespace ams::i2c::driver::impl { /* Wait for flush to finish, check every ms for 5 ms. */ for (size_t i = 0; i < 5; i++) { - R_UNLESS((reg::Read(&this->i2c_registers->I2C_FIFO_CONTROL_0) & 3), ResultSuccess()); + const bool flush_done = (reg::Read(&this->i2c_registers->I2C_FIFO_CONTROL_0) & 3) == 0; + R_SUCCEED_IF(flush_done); svcSleepThread(1'000'000ul); } @@ -418,7 +419,8 @@ namespace ams::i2c::driver::impl { Result BusAccessor::GetAndHandleTransactionResult() { const auto transaction_result = this->GetTransactionResult(); - R_UNLESS(R_FAILED(transaction_result), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(transaction_result)); + this->HandleTransactionResult(transaction_result); this->ClearInterruptMask(); this->interrupt_event.Reset(); diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index 3b3ede1ab..b94d9c83d 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -602,7 +602,7 @@ namespace ams::dmnt::cheat::impl { { if (this->HasActiveCheatProcess()) { /* When forcing attach, we're done. */ - R_UNLESS(on_process_launch, ResultSuccess()); + R_SUCCEED_IF(!on_process_launch); } /* Detach from the current process, if it's open. */ diff --git a/stratosphere/dmnt/source/dmnt_service_target_io.cpp b/stratosphere/dmnt/source/dmnt_service_target_io.cpp index 50ffbd995..41ac24abf 100644 --- a/stratosphere/dmnt/source/dmnt_service_target_io.cpp +++ b/stratosphere/dmnt/source/dmnt_service_target_io.cpp @@ -49,7 +49,7 @@ namespace ams::dmnt { Result EnsureSdInitialized() { std::scoped_lock lk(g_sd_lock); - R_UNLESS(!g_sd_initialized, ResultSuccess()); + R_SUCCEED_IF(g_sd_initialized); R_TRY(fsOpenSdCardFileSystem(&g_sd_fs)); g_sd_initialized = true; diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index 3f895cac6..9e403af0f 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -64,8 +64,8 @@ namespace ams::fatal::srv { /* Throw implementation. */ Result ServiceContext::ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalPolicy policy, const CpuContext &cpu_ctx) { - /* We don't support Error Report only fatals. */ - R_UNLESS(policy != FatalPolicy_ErrorReport, ResultSuccess()); + /* We don't support Error-Report-only fatals. */ + R_SUCCEED_IF(policy == FatalPolicy_ErrorReport); /* Note that we've thrown fatal. */ R_TRY(this->TrySetHasThrown()); diff --git a/stratosphere/loader/source/ldr_content_management.cpp b/stratosphere/loader/source/ldr_content_management.cpp index 7c5d2028b..a837941e3 100644 --- a/stratosphere/loader/source/ldr_content_management.cpp +++ b/stratosphere/loader/source/ldr_content_management.cpp @@ -307,7 +307,7 @@ namespace ams::ldr { R_TRY(lr::OpenLocationResolver(std::addressof(lr), static_cast(loc.storage_id))); /* If there's already a Html Document path, we don't need to set one. */ - R_UNLESS(R_FAILED(lr.ResolveApplicationHtmlDocumentPath(std::addressof(path), loc.program_id)), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(lr.ResolveApplicationHtmlDocumentPath(std::addressof(path), loc.program_id))); /* We just need to set this to any valid NCA path. Let's use the executable path. */ R_TRY(lr.ResolveProgramPath(std::addressof(path), loc.program_id)); diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index a6e156e1f..2ef0b4146 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -84,7 +84,10 @@ namespace ams::ldr { #include "ldr_anti_downgrade_tables.inc" Result ValidateProgramVersion(ncm::ProgramId program_id, u32 version) { - R_UNLESS(hos::GetVersion() >= hos::Version_810, ResultSuccess()); + /* No version verification is done before 8.1.0. */ + R_SUCCEED_IF(hos::GetVersion() < hos::Version_810); + + /* Do version-dependent validation, if compiled to do so. */ #ifdef LDR_VALIDATE_PROCESS_VERSION const MinimumProgramVersion *entries = nullptr; size_t num_entries = 0; diff --git a/stratosphere/sm/source/impl/sm_service_manager.cpp b/stratosphere/sm/source/impl/sm_service_manager.cpp index e5b5e49b9..ff2d03ac4 100644 --- a/stratosphere/sm/source/impl/sm_service_manager.cpp +++ b/stratosphere/sm/source/impl/sm_service_manager.cpp @@ -297,7 +297,7 @@ namespace ams::sm::impl { is_valid &= std::memcmp(&ac_service, &service, access_control.GetServiceNameSize() - 1) == 0; } - R_UNLESS(!is_valid, ResultSuccess()); + R_SUCCEED_IF(is_valid); } access_control = access_control.GetNextEntry(); }