diff --git a/exosphere/mariko_fatal/source/fatal_sdmmc.cpp b/exosphere/mariko_fatal/source/fatal_sdmmc.cpp index ef7035682..3e498b7b8 100644 --- a/exosphere/mariko_fatal/source/fatal_sdmmc.cpp +++ b/exosphere/mariko_fatal/source/fatal_sdmmc.cpp @@ -58,6 +58,7 @@ namespace ams::secmon::fatal { Result ReadSdCard(void *dst, size_t size, size_t sector_index, size_t sector_count) { /* Validate that our buffer is valid. */ AMS_ASSERT(size >= sector_count * sdmmc::SectorSize); + AMS_UNUSED(size); /* Repeatedly read sectors. */ u8 *dst_u8 = static_cast(dst); @@ -83,6 +84,7 @@ namespace ams::secmon::fatal { Result WriteSdCard(size_t sector_index, size_t sector_count, const void *src, size_t size) { /* Validate that our buffer is valid. */ AMS_ASSERT(size >= sector_count * sdmmc::SectorSize); + AMS_UNUSED(size); /* Repeatedly read sectors. */ const u8 *src_u8 = static_cast(src); diff --git a/libraries/libexosphere/source/crypto/crypto_aes_impl_security_engine.cpp b/libraries/libexosphere/source/crypto/crypto_aes_impl_security_engine.cpp index 54fab167e..0055de691 100644 --- a/libraries/libexosphere/source/crypto/crypto_aes_impl_security_engine.cpp +++ b/libraries/libexosphere/source/crypto/crypto_aes_impl_security_engine.cpp @@ -34,7 +34,7 @@ namespace ams::crypto::impl { void AesImpl::Initialize(const void *key, size_t key_size, bool is_encrypt) { static_assert(IsSupportedKeySize(KeySize)); AMS_ASSERT(key_size == sizeof(int)); - AMS_UNUSED(is_encrypt); + AMS_UNUSED(key_size, is_encrypt); /* Set the security engine keyslot. */ this->slot = *static_cast(key); diff --git a/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp b/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp index 72338075b..fba40969b 100644 --- a/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp +++ b/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp @@ -29,6 +29,7 @@ namespace ams::ddsf { for (const auto &holder : this->entry_list) { AMS_ASSERT(holder.IsConstructed()); AMS_ASSERT(holder.Get().GetDeviceCode() != device_code); + AMS_UNUSED(holder); } /* Allocate memory for a new device code entry holder. */ diff --git a/libraries/libstratosphere/source/err/impl/err_string_util.cpp b/libraries/libstratosphere/source/err/impl/err_string_util.cpp index f5842da5e..c326ea49e 100644 --- a/libraries/libstratosphere/source/err/impl/err_string_util.cpp +++ b/libraries/libstratosphere/source/err/impl/err_string_util.cpp @@ -21,6 +21,7 @@ namespace ams::err::impl { void MakeErrorCodeString(char *dst, size_t dst_size, ErrorCode error_code) { const auto len = util::TSNPrintf(dst, dst_size, "%04d-%04d", error_code.category, error_code.number); AMS_ASSERT(static_cast(len) < dst_size); + AMS_UNUSED(len); } } diff --git a/libraries/libstratosphere/source/fs/fs_access_log.cpp b/libraries/libstratosphere/source/fs/fs_access_log.cpp index 5e18e3cd2..5d3a961a6 100644 --- a/libraries/libstratosphere/source/fs/fs_access_log.cpp +++ b/libraries/libstratosphere/source/fs/fs_access_log.cpp @@ -82,6 +82,7 @@ namespace ams::fs::impl { const char *IdString::ToValueString(int id) { const int len = util::SNPrintf(this->buffer, sizeof(this->buffer), "%d", id); AMS_ASSERT(static_cast(len) < sizeof(this->buffer)); + AMS_UNUSED(len); return this->buffer; } diff --git a/libraries/libstratosphere/source/fs/fs_bis.cpp b/libraries/libstratosphere/source/fs/fs_bis.cpp index da396e6a0..17ba65087 100644 --- a/libraries/libstratosphere/source/fs/fs_bis.cpp +++ b/libraries/libstratosphere/source/fs/fs_bis.cpp @@ -33,8 +33,9 @@ namespace ams::fs { AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ - auto size = util::SNPrintf(dst, dst_size, "%s:", bis_mount_name); + const auto size = util::SNPrintf(dst, dst_size, "%s:", bis_mount_name); AMS_ASSERT(static_cast(size) == needed_size - 1); + AMS_UNUSED(size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fs/fs_content_storage.cpp b/libraries/libstratosphere/source/fs/fs_content_storage.cpp index 96b31fb5b..5429be3d0 100644 --- a/libraries/libstratosphere/source/fs/fs_content_storage.cpp +++ b/libraries/libstratosphere/source/fs/fs_content_storage.cpp @@ -32,8 +32,9 @@ namespace ams::fs { AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ - auto size = util::SNPrintf(dst, dst_size, "%s:", GetContentStorageMountName(id)); + const auto size = util::SNPrintf(dst, dst_size, "%s:", GetContentStorageMountName(id)); AMS_ASSERT(static_cast(size) == needed_size - 1); + AMS_UNUSED(size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fs/fs_game_card.cpp b/libraries/libstratosphere/source/fs/fs_game_card.cpp index 1e9739300..a3c17806a 100644 --- a/libraries/libstratosphere/source/fs/fs_game_card.cpp +++ b/libraries/libstratosphere/source/fs/fs_game_card.cpp @@ -42,8 +42,9 @@ namespace ams::fs { AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ - auto size = util::SNPrintf(dst, dst_size, "%s%s%08x:", impl::GameCardFileSystemMountName, GetGameCardMountNameSuffix(this->partition), this->handle); + const auto size = util::SNPrintf(dst, dst_size, "%s%s%08x:", impl::GameCardFileSystemMountName, GetGameCardMountNameSuffix(this->partition), this->handle); AMS_ASSERT(static_cast(size) == needed_size - 1); + AMS_UNUSED(size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fs/fs_path_normalizer.cpp b/libraries/libstratosphere/source/fs/fs_path_normalizer.cpp index 7f1beadba..800ea936a 100644 --- a/libraries/libstratosphere/source/fs/fs_path_normalizer.cpp +++ b/libraries/libstratosphere/source/fs/fs_path_normalizer.cpp @@ -426,8 +426,9 @@ namespace ams::fs { { bool normalized = false; const auto is_norm_result = IsNormalized(std::addressof(normalized), out, unc_preserved, has_mount_name); - AMS_ASSERT(R_SUCCEEDED(is_norm_result)); + R_ASSERT(is_norm_result); AMS_ASSERT(normalized); + AMS_UNUSED(is_norm_result, normalized); } return ResultSuccess(); diff --git a/libraries/libstratosphere/source/fs/fs_path_utils.cpp b/libraries/libstratosphere/source/fs/fs_path_utils.cpp index 8239e713c..0837e8df8 100644 --- a/libraries/libstratosphere/source/fs/fs_path_utils.cpp +++ b/libraries/libstratosphere/source/fs/fs_path_utils.cpp @@ -29,8 +29,11 @@ namespace ams::fs { u32 *dst_invalid = this->invalid_chars; for (const char *cur = ":*?<>|"; *cur != '\x00'; ++cur) { AMS_ASSERT(dst_invalid < std::end(this->invalid_chars)); + const auto result = util::ConvertCharacterUtf8ToUtf32(dst_invalid, cur); AMS_ASSERT(result == util::CharacterEncodingResult_Success); + AMS_UNUSED(result); + ++dst_invalid; } AMS_ASSERT(dst_invalid == std::end(this->invalid_chars)); @@ -39,8 +42,11 @@ namespace ams::fs { u32 *dst_sep = this->separators; for (const char *cur = "/\\"; *cur != '\x00'; ++cur) { AMS_ASSERT(dst_sep < std::end(this->separators)); + const auto result = util::ConvertCharacterUtf8ToUtf32(dst_sep, cur); AMS_ASSERT(result == util::CharacterEncodingResult_Success); + AMS_UNUSED(result); + ++dst_sep; } AMS_ASSERT(dst_sep == std::end(this->separators)); diff --git a/libraries/libstratosphere/source/fs/fs_sd_card.cpp b/libraries/libstratosphere/source/fs/fs_sd_card.cpp index b11982b11..079b0306f 100644 --- a/libraries/libstratosphere/source/fs/fs_sd_card.cpp +++ b/libraries/libstratosphere/source/fs/fs_sd_card.cpp @@ -35,8 +35,9 @@ namespace ams::fs { AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ - auto size = util::SNPrintf(dst, dst_size, "%s:", impl::SdCardFileSystemMountName); + const auto size = util::SNPrintf(dst, dst_size, "%s:", impl::SdCardFileSystemMountName); AMS_ASSERT(static_cast(size) == needed_size - 1); + AMS_UNUSED(size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp b/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp index 19b74a6cf..7f6c8f3c3 100644 --- a/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp +++ b/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp @@ -215,9 +215,12 @@ namespace ams::fssystem { AMS_ASSERT(entry != nullptr); /* Ensure the entry is valid. */ - const auto entry_buffer = this->external_entry_buffer != nullptr ? this->external_entry_buffer : this->internal_entry_buffer.get(); - AMS_ASSERT(static_cast(entry_buffer) <= static_cast(entry)); - AMS_ASSERT(static_cast(entry) < static_cast(entry_buffer + this->entry_buffer_size)); + { + const auto entry_buffer = this->external_entry_buffer != nullptr ? this->external_entry_buffer : this->internal_entry_buffer.get(); + AMS_ASSERT(static_cast(entry_buffer) <= static_cast(entry)); + AMS_ASSERT(static_cast(entry) < static_cast(entry_buffer + this->entry_buffer_size)); + AMS_UNUSED(entry_buffer); + } /* Copy the entries back by one. */ std::memmove(entry, entry + 1, sizeof(Entry) * (this->entry_count - ((entry + 1) - this->entries))); diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp index 983806db1..2379ab20b 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp @@ -786,6 +786,7 @@ namespace ams::fssystem::save { /* Get the entry to invalidate. */ const CacheEntry *entry_to_invalidate = std::addressof(this->entries[this->invalidate_index]); + AMS_UNUSED(entry_to_invalidate); /* Ensure that the entry can be invalidated. */ AMS_ASSERT(entry_to_invalidate->is_valid); diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp index ea41aac8a..38f0c66c4 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp @@ -192,6 +192,7 @@ namespace ams::fssystem::save { const auto cache_buffer = reinterpret_cast(this->memory_range.first) + read_offset; AMS_ASSERT(read_offset >= 0); AMS_ASSERT(static_cast(read_offset) <= readable_offset_max); + AMS_UNUSED(readable_offset_max); std::memcpy(buffer, cache_buffer, size); } @@ -209,6 +210,7 @@ namespace ams::fssystem::save { const auto cache_buffer = reinterpret_cast(this->memory_range.first) + write_offset; AMS_ASSERT(write_offset >= 0); AMS_ASSERT(static_cast(write_offset) <= writable_offset_max); + AMS_UNUSED(writable_offset_max); std::memcpy(cache_buffer, buffer, size); this->is_dirty = true; diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp index 9a3b6402e..04f39a73d 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp @@ -44,9 +44,10 @@ namespace ams::fssystem::save { { s64 hash_size = 0; s64 data_size = 0; - AMS_ASSERT(R_SUCCEEDED(hash_storage.GetSize(std::addressof(hash_size)))); - AMS_ASSERT(R_SUCCEEDED(data_storage.GetSize(std::addressof(hash_size)))); + R_ASSERT(hash_storage.GetSize(std::addressof(hash_size))); + R_ASSERT(data_storage.GetSize(std::addressof(hash_size))); AMS_ASSERT(((hash_size / HashSize) * this->verification_block_size) >= data_size); + AMS_UNUSED(hash_size, data_size); } /* Set salt. */ diff --git a/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp b/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp index 9e8f7c805..4ec5e79e1 100644 --- a/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp +++ b/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp @@ -141,6 +141,7 @@ namespace ams::gpio::driver::impl { auto &pad = this->GetDevice().SafeCastTo(); auto &driver = pad.GetDriver().SafeCastTo(); AMS_ASSERT(driver.GetInterruptControlMutex(pad).IsLockedByCurrentThread()); + AMS_UNUSED(pad, driver); if (auto *event = this->event_holder.GetSystemEvent(); event != nullptr) { os::SignalSystemEvent(event); diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client.cpp b/libraries/libstratosphere/source/htcfs/htcfs_client.cpp index d1920972e..b1c342ecb 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client.cpp @@ -21,7 +21,7 @@ namespace ams::htcfs { namespace { constinit util::TypedStorage g_client_storage; - constinit bool g_initialized; + [[maybe_unused]] constinit bool g_initialized; } diff --git a/libraries/libstratosphere/source/htcs/impl/rpc/htcs_rpc_select_task.cpp b/libraries/libstratosphere/source/htcs/impl/rpc/htcs_rpc_select_task.cpp index 09e1507a9..a67d78d39 100644 --- a/libraries/libstratosphere/source/htcs/impl/rpc/htcs_rpc_select_task.cpp +++ b/libraries/libstratosphere/source/htcs/impl/rpc/htcs_rpc_select_task.cpp @@ -49,6 +49,7 @@ namespace ams::htcs::impl::rpc { AMS_ASSERT(0 <= write_handle_count && write_handle_count < SocketCountMax); AMS_ASSERT(0 <= exception_handle_count && exception_handle_count < SocketCountMax); AMS_ASSERT(handle_count * static_cast(sizeof(s32)) == body_size); + AMS_UNUSED(handle_count); /* Set our results. */ m_err = err; diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp index 7f70a68ba..241801d69 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp @@ -63,8 +63,11 @@ namespace ams::mem::impl::heap { bool CachedHeap::CheckCache() { bool cache = false; - auto err = this->Query(AllocQuery_CheckCache, std::addressof(cache)); - AMS_ASSERT(err != 0); + + const auto err = this->Query(AllocQuery_CheckCache, std::addressof(cache)); + AMS_ASSERT(err == 0); + AMS_UNUSED(err); + return cache; } diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp index ad61b81ab..37f18bc13 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp @@ -1151,8 +1151,9 @@ namespace ams::mem::impl::heap { } if (start_alignup < end_aligndown) { - auto err = this->FreePhysical(reinterpret_cast(start_alignup), end_aligndown - start_alignup); + const auto err = this->FreePhysical(reinterpret_cast(start_alignup), end_aligndown - start_alignup); AMS_ASSERT(err == 0); + AMS_UNUSED(err); } } else { this->MergeIntoFreeList(span); diff --git a/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp b/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp index c76928585..22d6ce8e8 100644 --- a/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp +++ b/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp @@ -167,8 +167,9 @@ namespace ams::mem { } } - auto err = GetCentral(this->central_heap_storage)->Free(ptr); + const auto err = GetCentral(this->central_heap_storage)->Free(ptr); AMS_ASSERT(err == 0); + AMS_UNUSED(err); } void *StandardAllocator::Reallocate(void *ptr, size_t new_size) { @@ -248,8 +249,9 @@ namespace ams::mem { void StandardAllocator::CleanUpManagementArea() const { AMS_ASSERT(this->initialized); - auto err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_UnifyFreeList); + const auto err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_UnifyFreeList); AMS_ASSERT(err == 0); + AMS_UNUSED(err); } size_t StandardAllocator::GetSizeOf(const void *ptr) const { diff --git a/libraries/libstratosphere/source/os/impl/os_address_space_allocator_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_address_space_allocator_impl.os.horizon.hpp index 925fc17fe..3c4e072a4 100644 --- a/libraries/libstratosphere/source/os/impl/os_address_space_allocator_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_address_space_allocator_impl.os.horizon.hpp @@ -23,7 +23,8 @@ namespace ams::os::impl { svc::MemoryInfo memory_info; svc::PageInfo page_info; const auto result = svc::QueryMemory(std::addressof(memory_info), std::addressof(page_info), address); - AMS_ASSERT(R_SUCCEEDED(result)); + R_ASSERT(result); + AMS_UNUSED(result); return memory_info.state == svc::MemoryState_Free && address + size <= memory_info.addr + memory_info.size; } diff --git a/libraries/libstratosphere/source/os/impl/os_message_queue_helper.hpp b/libraries/libstratosphere/source/os/impl/os_message_queue_helper.hpp index f39ed66e0..aab783268 100644 --- a/libraries/libstratosphere/source/os/impl/os_message_queue_helper.hpp +++ b/libraries/libstratosphere/source/os/impl/os_message_queue_helper.hpp @@ -109,6 +109,7 @@ namespace ams::os::impl { const auto count = mq->count; const auto offset = mq->offset; AMS_ASSERT(count > 0); + AMS_UNUSED(count); return mq->buffer[offset]; } diff --git a/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.cpp b/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.cpp index 209cc9848..004d874f3 100644 --- a/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.cpp +++ b/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.cpp @@ -38,8 +38,9 @@ namespace ams::os::impl { const s64 frac = tick_val % tick_freq; const TimeSpan ts = TimeSpan::FromSeconds(seconds) + TimeSpan::FromNanoSeconds(frac * NanoSecondsPerSecond / tick_freq); - constexpr TimeSpan ZeroTS = TimeSpan::FromNanoSeconds(0); + constexpr TimeSpan ZeroTS = TimeSpan::FromNanoSeconds(0); AMS_ASSERT(!((tick_val > 0 && ts < ZeroTS) || (tick_val < 0 && ts > ZeroTS))); + AMS_UNUSED(ZeroTS); return ts; } diff --git a/libraries/libstratosphere/source/os/impl/os_waitable_manager_impl.hpp b/libraries/libstratosphere/source/os/impl/os_waitable_manager_impl.hpp index e74ed53e6..9ac6df9c0 100644 --- a/libraries/libstratosphere/source/os/impl/os_waitable_manager_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_waitable_manager_impl.hpp @@ -49,8 +49,11 @@ namespace ams::os::impl { WaitableHolderBase *WaitAnyImpl(bool infinite, TimeSpan timeout) { WaitableHolderBase *holder = nullptr; + const Result wait_result = this->WaitAnyImpl(std::addressof(holder), infinite, timeout, false, svc::InvalidHandle); - AMS_ASSERT(R_SUCCEEDED(wait_result)); + R_ASSERT(wait_result); + AMS_UNUSED(wait_result); + return holder; } public: diff --git a/libraries/libstratosphere/source/os/os_thread.cpp b/libraries/libstratosphere/source/os/os_thread.cpp index 1dcbb2de3..45a8b6948 100644 --- a/libraries/libstratosphere/source/os/os_thread.cpp +++ b/libraries/libstratosphere/source/os/os_thread.cpp @@ -123,8 +123,9 @@ namespace ams::os { const s32 prev_prio = thread->base_priority; - bool success = impl::GetThreadManager().ChangePriority(thread, priority); + const bool success = impl::GetThreadManager().ChangePriority(thread, priority); AMS_ASSERT(success); + AMS_UNUSED(success); thread->base_priority = priority; diff --git a/libraries/libstratosphere/source/os/os_waitable.cpp b/libraries/libstratosphere/source/os/os_waitable.cpp index 3aed7da6f..2df27e6db 100644 --- a/libraries/libstratosphere/source/os/os_waitable.cpp +++ b/libraries/libstratosphere/source/os/os_waitable.cpp @@ -45,6 +45,7 @@ namespace ams::os { AMS_ASSERT(manager->state == WaitableManagerType::State_Initialized); AMS_ASSERT(impl.IsEmpty()); + AMS_UNUSED(impl); /* Mark not initialized. */ manager->state = WaitableManagerType::State_NotInitialized; diff --git a/libraries/libvapours/include/vapours/assert.hpp b/libraries/libvapours/include/vapours/assert.hpp index 79882bd44..1b06f2dfc 100644 --- a/libraries/libvapours/include/vapours/assert.hpp +++ b/libraries/libvapours/include/vapours/assert.hpp @@ -42,8 +42,10 @@ namespace ams::diag { AMS_CALL_ASSERT_FAIL_IMPL(#expr, ## __VA_ARGS__); \ } \ }) -#else +#elif defined(AMS_PRESERVE_ASSERTION_EXPRESSIONS) #define AMS_ASSERT_IMPL(expr, ...) AMS_UNUSED(expr, ## __VA_ARGS__) +#else +#define AMS_ASSERT_IMPL(expr, ...) static_cast(0) #endif #define AMS_ASSERT(expr, ...) AMS_ASSERT_IMPL(expr, ## __VA_ARGS__) @@ -52,8 +54,10 @@ namespace ams::diag { #ifdef AMS_BUILD_FOR_AUDITING #define AMS_AUDIT(expr, ...) AMS_ASSERT(expr, ## __VA_ARGS__) -#else +#elif defined(AMS_PRESERVE_AUDIT_EXPRESSIONS) #define AMS_AUDIT(expr, ...) AMS_UNUSED(expr, ## __VA_ARGS__) +#else +#define AMS_AUDIT(expr, ...) static_cast(0) #endif #define AMS_ABORT(...) AMS_CALL_ABORT_IMPL("", ## __VA_ARGS__) diff --git a/libraries/libvapours/include/vapours/crypto/crypto_rsa_pss_verifier.hpp b/libraries/libvapours/include/vapours/crypto/crypto_rsa_pss_verifier.hpp index 273854489..536bd480f 100644 --- a/libraries/libvapours/include/vapours/crypto/crypto_rsa_pss_verifier.hpp +++ b/libraries/libvapours/include/vapours/crypto/crypto_rsa_pss_verifier.hpp @@ -65,6 +65,7 @@ namespace ams::crypto { bool Verify(const void *signature, size_t size) { AMS_ASSERT(this->state == State::Initialized); AMS_ASSERT(size == SignatureSize); + AMS_UNUSED(size); ON_SCOPE_EXIT { this->state = State::Done; }; impl::RsaPssImpl impl; @@ -85,6 +86,7 @@ namespace ams::crypto { bool Verify(const void *signature, size_t size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(this->state == State::Initialized); AMS_ASSERT(size == SignatureSize); + AMS_UNUSED(size); ON_SCOPE_EXIT { this->state = State::Done; }; impl::RsaPssImpl impl; @@ -105,6 +107,7 @@ namespace ams::crypto { bool VerifyWithHash(const void *signature, size_t size, const void *hash, size_t hash_size) { AMS_ASSERT(this->state == State::Initialized); AMS_ASSERT(size == SignatureSize); + AMS_UNUSED(size); ON_SCOPE_EXIT { this->state = State::Done; }; impl::RsaPssImpl impl; @@ -121,6 +124,7 @@ namespace ams::crypto { bool VerifyWithHash(const void *signature, size_t size, const void *hash, size_t hash_size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(this->state == State::Initialized); AMS_ASSERT(size == SignatureSize); + AMS_UNUSED(size); ON_SCOPE_EXIT { this->state = State::Done; }; impl::RsaPssImpl impl; diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_bignum.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_bignum.hpp index 37cea25bc..7857e267e 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_bignum.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_bignum.hpp @@ -71,6 +71,7 @@ namespace ams::crypto::impl { this->count += num; AMS_ASSERT(words == this->buffer); + AMS_UNUSED(words); } public: constexpr ALWAYS_INLINE WordAllocator(Word *buf, size_t c) : buffer(buf), count(c), max_count(c), min_count(c) { /* ... */ } diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_ctr_mode_impl.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_ctr_mode_impl.hpp index df5955d68..90f5a78e6 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_ctr_mode_impl.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_ctr_mode_impl.hpp @@ -96,6 +96,7 @@ namespace ams::crypto::impl { size_t Update(void *_dst, size_t dst_size, const void *_src, size_t src_size) { AMS_ASSERT(this->state == State_Initialized); AMS_ASSERT(dst_size >= src_size); + AMS_UNUSED(dst_size); u8 *dst = static_cast(_dst); const u8 *src = static_cast(_src); diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_hmac_impl.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_hmac_impl.hpp index 961506b40..efd48134a 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_hmac_impl.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_hmac_impl.hpp @@ -99,6 +99,7 @@ namespace ams::crypto::impl { inline void HmacImpl::GetMac(void *dst, size_t dst_size) { AMS_ASSERT(this->state == State_Initialized || this->state == State_Done); AMS_ASSERT(dst_size >= MacSize); + AMS_UNUSED(dst_size); /* If we're not already finalized, get the final mac. */ if (this->state == State_Initialized) { diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_oaep_impl.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_oaep_impl.hpp index cc0e59563..89706b5b7 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_oaep_impl.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_oaep_impl.hpp @@ -85,6 +85,7 @@ namespace ams::crypto::impl { AMS_ASSERT(salt_size > 0); AMS_ASSERT(salt_size == HashSize); AMS_ASSERT(label_digest_size == HashSize); + AMS_UNUSED(salt_size, label_digest_size); u8 *buf = static_cast(dst); buf[0] = HeadMagic; @@ -109,6 +110,7 @@ namespace ams::crypto::impl { AMS_ABORT_UNLESS(dst_size > 0); AMS_ABORT_UNLESS(buf_size >= 2 * HashSize + 3); AMS_ABORT_UNLESS(label_digest_size == HashSize); + AMS_UNUSED(label_digest_size); /* Validate sanity byte. */ bool is_valid = buf[0] == HeadMagic; diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_pss_impl.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_pss_impl.hpp index 3febb5aba..d59587f5d 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_pss_impl.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_pss_impl.hpp @@ -33,6 +33,7 @@ namespace ams::crypto::impl { private: static void ComputeHashWithPadding(void *dst, const u8 *user_hash, size_t user_hash_size, const void *salt, size_t salt_size) { AMS_ASSERT(user_hash_size == HashSize); + AMS_UNUSED(user_hash_size); /* Initialize our buffer. */ u8 buf[8 + HashSize]; diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_sha256_impl.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_sha256_impl.hpp index ab9b69710..1a485e361 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_sha256_impl.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_sha256_impl.hpp @@ -61,6 +61,7 @@ namespace ams::crypto::impl { void GetBufferedData(void *dst, size_t dst_size) const { AMS_ASSERT(dst_size >= this->GetBufferedDataSize()); + AMS_UNUSED(dst_size); std::memcpy(dst, this->state.buffer, this->GetBufferedDataSize()); } diff --git a/libraries/libvapours/include/vapours/crypto/impl/crypto_xts_mode_impl.hpp b/libraries/libvapours/include/vapours/crypto/impl/crypto_xts_mode_impl.hpp index 4129e5595..3963ffba1 100644 --- a/libraries/libvapours/include/vapours/crypto/impl/crypto_xts_mode_impl.hpp +++ b/libraries/libvapours/include/vapours/crypto/impl/crypto_xts_mode_impl.hpp @@ -65,6 +65,7 @@ namespace ams::crypto::impl { template void Initialize(const BlockCipher *cipher, const void *tweak, size_t tweak_size) { AMS_ASSERT(tweak_size == IvSize); + AMS_UNUSED(tweak_size); cipher->EncryptBlock(this->tweak, IvSize, tweak, IvSize); diff --git a/libraries/libvapours/source/crypto/impl/crypto_gcm_mode_impl.arch.arm64.cpp b/libraries/libvapours/source/crypto/impl/crypto_gcm_mode_impl.arch.arm64.cpp index 9b6ba6c4b..d12f8ddc9 100644 --- a/libraries/libvapours/source/crypto/impl/crypto_gcm_mode_impl.arch.arm64.cpp +++ b/libraries/libvapours/source/crypto/impl/crypto_gcm_mode_impl.arch.arm64.cpp @@ -239,6 +239,7 @@ namespace ams::crypto::impl { AMS_ASSERT(dst_size >= MacSize); AMS_ASSERT(this->aad_remaining == 0); AMS_ASSERT(this->msg_remaining == 0); + AMS_UNUSED(dst_size); /* If we haven't already done so, compute the final mac. */ if (this->state != State_Done) { diff --git a/stratosphere/erpt/source/erpt_main.cpp b/stratosphere/erpt/source/erpt_main.cpp index e7d0eb9cd..9905d2eb8 100644 --- a/stratosphere/erpt/source/erpt_main.cpp +++ b/stratosphere/erpt/source/erpt_main.cpp @@ -173,6 +173,7 @@ int main(int argc, char **argv) char os_private[0x60]; const auto os_priv_len = util::SNPrintf(os_private, sizeof(os_private), "%s (%.8s)", firmware_version.display_name, firmware_version.revision); AMS_ASSERT(static_cast(os_priv_len) < sizeof(os_private)); + AMS_UNUSED(os_priv_len); R_ABORT_UNLESS(erpt::srv::SetSerialNumberAndOsVersion(serial_number.str, strnlen(serial_number.str, sizeof(serial_number.str) - 1) + 1, @@ -187,6 +188,8 @@ int main(int argc, char **argv) char product_model[0x10]; const auto pm_len = erpt::MakeProductModelString(product_model, sizeof(product_model), settings::system::GetProductModel()); AMS_ASSERT(static_cast(pm_len) < sizeof(product_model)); + AMS_UNUSED(pm_len); + R_ABORT_UNLESS(erpt::srv::SetProductModel(product_model, static_cast(std::strlen(product_model)))); }