From 73798cb812cb7f8bb3e2aeeea2b07b941331c79f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 17 Aug 2020 14:20:24 -0700 Subject: [PATCH] kern: build with -Wextra --- libraries/config/templates/mesosphere.mk | 2 +- libraries/libmesosphere/Makefile | 2 +- .../include/mesosphere/kern_k_typed_address.hpp | 3 +++ .../include/mesosphere/kern_panic.hpp | 7 +------ .../libmesosphere/source/arch/arm64/kern_cpu.cpp | 4 ++++ .../source/arch/arm64/kern_k_hardware_timer.cpp | 1 + .../source/arch/arm64/kern_k_page_table.cpp | 7 ++++++- .../source/arch/arm64/kern_k_thread_context.cpp | 1 + libraries/libmesosphere/source/kern_debug_log.cpp | 2 ++ .../libmesosphere/source/kern_initial_process.cpp | 2 +- .../libmesosphere/source/kern_k_capabilities.cpp | 1 + .../libmesosphere/source/kern_k_dpc_manager.cpp | 8 ++++++++ .../source/kern_k_interrupt_event.cpp | 2 +- .../libmesosphere/source/kern_k_memory_layout.cpp | 4 ++++ .../source/kern_k_memory_manager.cpp | 1 - .../source/kern_k_page_table_base.cpp | 5 ++++- libraries/libmesosphere/source/kern_k_process.cpp | 6 ++++++ .../libmesosphere/source/kern_k_scheduler.cpp | 1 + .../source/kern_k_server_session.cpp | 14 ++++++++++++-- .../libmesosphere/source/kern_k_shared_memory.cpp | 1 + libraries/libmesosphere/source/kern_panic.cpp | 2 ++ .../source/svc/kern_svc_kernel_debug.cpp | 8 ++++++++ libraries/libvapours/include/vapours/assert.hpp | 11 ----------- libraries/libvapours/include/vapours/defines.hpp | 15 +++++++++++++++ .../include/vapours/results/results_common.hpp | 2 +- .../impl/svc_codegen_impl_kernel_svc_wrapper.hpp | 6 +++++- .../impl/svc_codegen_impl_layout_conversion.hpp | 2 +- .../vapours/svc/ipc/svc_message_buffer.hpp | 1 + libraries/libvapours/include/vapours/timespan.hpp | 2 +- .../include/vapours/util/util_intrusive_list.hpp | 2 ++ .../source/crypto/impl/crypto_xts_mode_impl.cpp | 4 ++++ .../source/arch/arm64/init/kern_init_core.cpp | 1 + 32 files changed, 100 insertions(+), 30 deletions(-) diff --git a/libraries/config/templates/mesosphere.mk b/libraries/config/templates/mesosphere.mk index 98dcf1235..f3c84f5cc 100644 --- a/libraries/config/templates/mesosphere.mk +++ b/libraries/config/templates/mesosphere.mk @@ -7,7 +7,7 @@ include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../common.mk # options for code generation #--------------------------------------------------------------------------------- export DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_MESOSPHERE -export SETTINGS := $(ATMOSPHERE_SETTINGS) -O2 -mgeneral-regs-only -ffixed-x18 -Werror -fno-non-call-exceptions +export SETTINGS := $(ATMOSPHERE_SETTINGS) -O2 -mgeneral-regs-only -ffixed-x18 -Wextra -Werror -fno-non-call-exceptions export CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) export CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -fno-use-cxa-atexit export ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) $(DEFINES) diff --git a/libraries/libmesosphere/Makefile b/libraries/libmesosphere/Makefile index 2e416715c..8bef7afec 100644 --- a/libraries/libmesosphere/Makefile +++ b/libraries/libmesosphere/Makefile @@ -9,7 +9,7 @@ include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../config/common.mk PRECOMPILED_HEADERS := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/include/mesosphere.hpp DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_MESOSPHERE -SETTINGS := $(ATMOSPHERE_SETTINGS) -O2 -mgeneral-regs-only -ffixed-x18 -Werror -fno-non-call-exceptions +SETTINGS := $(ATMOSPHERE_SETTINGS) -O2 -mgeneral-regs-only -ffixed-x18 -Wextra -Werror -fno-non-call-exceptions CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -fno-use-cxa-atexit -flto ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp index bc291e0bd..82e1227e6 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_typed_address.hpp @@ -31,6 +31,9 @@ namespace ams::kern { template constexpr ALWAYS_INLINE explicit KTypedAddress(U *ptr) : address(reinterpret_cast(ptr)) { /* ... */ } + /* Copy constructor. */ + constexpr ALWAYS_INLINE KTypedAddress(const KTypedAddress &rhs) : address(rhs.address) { /* ... */ } + /* Assignment operator. */ constexpr ALWAYS_INLINE KTypedAddress operator=(KTypedAddress rhs) { this->address = rhs.address; diff --git a/libraries/libmesosphere/include/mesosphere/kern_panic.hpp b/libraries/libmesosphere/include/mesosphere/kern_panic.hpp index 4f3b2384b..9382de11e 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_panic.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_panic.hpp @@ -19,17 +19,12 @@ namespace ams::kern { - template - ALWAYS_INLINE void UnusedImpl(ArgTypes &&... args) { - (static_cast(args), ...); - } - NORETURN NOINLINE void Panic(const char *file, int line, const char *format, ...) __attribute__((format(printf, 3, 4))); NORETURN NOINLINE void Panic(); } -#define MESOSPHERE_UNUSED(...) ::ams::kern::UnusedImpl(__VA_ARGS__) +#define MESOSPHERE_UNUSED(...) AMS_UNUSED(__VA_ARGS__) #ifdef MESOSPHERE_ENABLE_DEBUG_PRINT #define MESOSPHERE_PANIC(...) do { ::ams::kern::Panic(__FILE__, __LINE__, ## __VA_ARGS__); } while(0) diff --git a/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp b/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp index 170ae14e0..8f571d374 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp @@ -37,6 +37,7 @@ namespace ams::kern::arch::arm64::cpu { constexpr KThreadTerminationInterruptHandler() : KInterruptHandler() { /* ... */ } virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override { + MESOSPHERE_UNUSED(interrupt_id); return nullptr; } }; @@ -68,6 +69,8 @@ namespace ams::kern::arch::arm64::cpu { /* Nintendo misuses this per their own API, but it's functional. */ virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override { + MESOSPHERE_UNUSED(interrupt_id); + if (this->which < 0) { this->counter = cpu::GetCycleCounter(); } else { @@ -145,6 +148,7 @@ namespace ams::kern::arch::arm64::cpu { } virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override { + MESOSPHERE_UNUSED(interrupt_id); this->ProcessOperation(); return nullptr; } diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp index 5a1630758..40420496f 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_hardware_timer.cpp @@ -24,6 +24,7 @@ namespace ams::kern::arch::arm64 { constexpr KHardwareTimerInterruptTask() : KInterruptTask() { /* ... */ } virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override { + MESOSPHERE_UNUSED(interrupt_id); return this; } 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 18e89bfad..f7722c7dc 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp @@ -160,6 +160,7 @@ namespace ams::kern::arch::arm64 { void KPageTable::Initialize(s32 core_id) { /* Nothing actually needed here. */ + MESOSPHERE_UNUSED(core_id); } Result KPageTable::InitializeForKernel(void *table, KVirtualAddress start, KVirtualAddress end) { @@ -181,7 +182,8 @@ namespace ams::kern::arch::arm64 { } Result KPageTable::InitializeForProcess(u32 id, ams::svc::CreateProcessFlag as_type, bool enable_aslr, bool from_back, KMemoryManager::Pool pool, KProcessAddress code_address, size_t code_size, KMemoryBlockSlabManager *mem_block_slab_manager, KBlockInfoManager *block_info_manager, KPageTableManager *pt_manager) { - /* Convert the address space type to a width. */ + /* The input ID isn't actually used. */ + MESOSPHERE_UNUSED(id); /* Get an ASID */ this->asid = g_asid_manager.Reserve(); @@ -364,6 +366,9 @@ namespace ams::kern::arch::arm64 { MESOSPHERE_ASSERT(util::IsAligned(GetInteger(phys_addr), L1BlockSize)); MESOSPHERE_ASSERT(util::IsAligned(num_pages * PageSize, L1BlockSize)); + /* Allocation is never needed for L1 block mapping. */ + MESOSPHERE_UNUSED(page_list, reuse_ll); + auto &impl = this->GetImpl(); /* Iterate, mapping each block. */ diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index 90ad97c8a..4009dce74 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -281,6 +281,7 @@ namespace ams::kern::arch::arm64 { } void KThreadContext::OnThreadTerminating(const KThread *thread) { + MESOSPHERE_UNUSED(thread); /* ... */ } diff --git a/libraries/libmesosphere/source/kern_debug_log.cpp b/libraries/libmesosphere/source/kern_debug_log.cpp index 6288f1df2..861859b8f 100644 --- a/libraries/libmesosphere/source/kern_debug_log.cpp +++ b/libraries/libmesosphere/source/kern_debug_log.cpp @@ -498,6 +498,8 @@ namespace ams::kern { R_TRY(PutUserString(user_str, len)); } + #else + MESOSPHERE_UNUSED(user_str, len); #endif return ResultSuccess(); diff --git a/libraries/libmesosphere/source/kern_initial_process.cpp b/libraries/libmesosphere/source/kern_initial_process.cpp index 598863894..ff0658be6 100644 --- a/libraries/libmesosphere/source/kern_initial_process.cpp +++ b/libraries/libmesosphere/source/kern_initial_process.cpp @@ -62,7 +62,7 @@ namespace ams::kern { /* Allocate memory for the process. */ auto &mm = Kernel::GetMemoryManager(); - const auto pool = static_cast(reader.UsesSecureMemory() ? KMemoryManager::Pool_System : KSystemControl::GetInitialProcessBinaryPool()); + const auto pool = reader.UsesSecureMemory() ? KMemoryManager::Pool_System : static_cast(KSystemControl::GetInitialProcessBinaryPool()); MESOSPHERE_R_ABORT_UNLESS(mm.Allocate(std::addressof(pg), params.code_num_pages, KMemoryManager::EncodeOption(pool, KMemoryManager::Direction_FromFront))); { diff --git a/libraries/libmesosphere/source/kern_k_capabilities.cpp b/libraries/libmesosphere/source/kern_k_capabilities.cpp index e8e5d2a86..169afc06d 100644 --- a/libraries/libmesosphere/source/kern_k_capabilities.cpp +++ b/libraries/libmesosphere/source/kern_k_capabilities.cpp @@ -157,6 +157,7 @@ namespace ams::kern { case RegionType::OnMemoryBootImage: case RegionType::DTB: R_TRY(page_table->MapRegion(MemoryRegions[static_cast(type)], perm)); + break; default: return svc::ResultNotFound(); } diff --git a/libraries/libmesosphere/source/kern_k_dpc_manager.cpp b/libraries/libmesosphere/source/kern_k_dpc_manager.cpp index 1113d5590..9fbcaf0bf 100644 --- a/libraries/libmesosphere/source/kern_k_dpc_manager.cpp +++ b/libraries/libmesosphere/source/kern_k_dpc_manager.cpp @@ -86,6 +86,10 @@ namespace ams::kern { /* Manager thread functions. */ void DpcManagerNormalThreadFunction(uintptr_t arg) { + /* Input argument goes unused. */ + MESOSPHERE_UNUSED(arg); + + /* Forever wait and service requests. */ while (true) { KDpcTask::WaitForRequest(); KDpcTask::HandleRequest(); @@ -93,6 +97,10 @@ namespace ams::kern { } void DpcManagerPreemptionThreadFunction(uintptr_t arg) { + /* Input argument goes unused. */ + MESOSPHERE_UNUSED(arg); + + /* Forever wait and service requests, rotating the scheduled queue every 10 ms. */ s64 timeout = KHardwareTimer::GetTick() + DpcManagerTimeout; while (true) { if (KDpcTask::TimedWaitForRequest(timeout)) { diff --git a/libraries/libmesosphere/source/kern_k_interrupt_event.cpp b/libraries/libmesosphere/source/kern_k_interrupt_event.cpp index b8e24f699..af0b4b21b 100644 --- a/libraries/libmesosphere/source/kern_k_interrupt_event.cpp +++ b/libraries/libmesosphere/source/kern_k_interrupt_event.cpp @@ -128,7 +128,7 @@ namespace ams::kern { KInterruptTask *KInterruptEventTask::OnInterrupt(s32 interrupt_id) { MESOSPHERE_ASSERT_THIS(); - + MESOSPHERE_UNUSED(interrupt_id); return this; } diff --git a/libraries/libmesosphere/source/kern_k_memory_layout.cpp b/libraries/libmesosphere/source/kern_k_memory_layout.cpp index e768f6af1..6ea5a2c43 100644 --- a/libraries/libmesosphere/source/kern_k_memory_layout.cpp +++ b/libraries/libmesosphere/source/kern_k_memory_layout.cpp @@ -188,6 +188,10 @@ namespace ams::kern { } void SetupCoreLocalRegionMemoryRegions(KInitialPageTable &page_table, KInitialPageAllocator &page_allocator) { + /* NOTE: Nintendo passes page table here to use num_l1_entries; we don't use this at present. */ + MESOSPHERE_UNUSED(page_table); + + /* Get the virtual address of the core local reigon. */ const KVirtualAddress core_local_virt_start = GetCoreLocalRegionVirtualAddress(); MESOSPHERE_INIT_ABORT_UNLESS(KMemoryLayout::GetVirtualMemoryRegionTree().Insert(GetInteger(core_local_virt_start), CoreLocalRegionSize, KMemoryRegionType_CoreLocal)); diff --git a/libraries/libmesosphere/source/kern_k_memory_manager.cpp b/libraries/libmesosphere/source/kern_k_memory_manager.cpp index 082c1db01..412d71c6d 100644 --- a/libraries/libmesosphere/source/kern_k_memory_manager.cpp +++ b/libraries/libmesosphere/source/kern_k_memory_manager.cpp @@ -203,7 +203,6 @@ namespace ams::kern { } /* Only succeed if we allocated as many pages as we wanted. */ - MESOSPHERE_ASSERT(num_pages >= 0); R_UNLESS(num_pages == 0, svc::ResultOutOfMemory()); /* We succeeded! */ diff --git a/libraries/libmesosphere/source/kern_k_page_table_base.cpp b/libraries/libmesosphere/source/kern_k_page_table_base.cpp index c489c0cca..5497ee4b6 100644 --- a/libraries/libmesosphere/source/kern_k_page_table_base.cpp +++ b/libraries/libmesosphere/source/kern_k_page_table_base.cpp @@ -2761,9 +2761,12 @@ namespace ams::kern { lk1.emplace(lock_1); } - /* Check memory state. */ + /* Check memory state for source. */ R_TRY(src_page_table.CheckMemoryStateContiguous(src_addr, size, src_state_mask, src_state, src_test_perm, src_test_perm, src_attr_mask | KMemoryAttribute_Uncached, src_attr)); + /* Destination state is intentionally unchecked. */ + MESOSPHERE_UNUSED(dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr); + /* Get implementations. */ auto &src_impl = src_page_table.GetImpl(); auto &dst_impl = dst_page_table.GetImpl(); diff --git a/libraries/libmesosphere/source/kern_k_process.cpp b/libraries/libmesosphere/source/kern_k_process.cpp index 051379f32..e5bf37f62 100644 --- a/libraries/libmesosphere/source/kern_k_process.cpp +++ b/libraries/libmesosphere/source/kern_k_process.cpp @@ -493,6 +493,9 @@ namespace ams::kern { /* Lock ourselves, to prevent concurrent access. */ KScopedLightLock lk(this->state_lock); + /* Address and size parameters aren't used. */ + MESOSPHERE_UNUSED(address, size); + /* Try to find an existing info for the memory. */ KSharedMemoryInfo *info = nullptr; for (auto it = this->shared_memory_list.begin(); it != this->shared_memory_list.end(); ++it) { @@ -524,6 +527,9 @@ namespace ams::kern { /* Lock ourselves, to prevent concurrent access. */ KScopedLightLock lk(this->state_lock); + /* Address and size parameters aren't used. */ + MESOSPHERE_UNUSED(address, size); + /* Find an existing info for the memory. */ KSharedMemoryInfo *info = nullptr; auto it = this->shared_memory_list.begin(); diff --git a/libraries/libmesosphere/source/kern_k_scheduler.cpp b/libraries/libmesosphere/source/kern_k_scheduler.cpp index ee1869557..05a25e1fa 100644 --- a/libraries/libmesosphere/source/kern_k_scheduler.cpp +++ b/libraries/libmesosphere/source/kern_k_scheduler.cpp @@ -28,6 +28,7 @@ namespace ams::kern { constexpr KSchedulerInterruptTask() : KInterruptTask() { /* ... */ } virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override { + MESOSPHERE_UNUSED(interrupt_id); return GetDummyInterruptTask(); } diff --git a/libraries/libmesosphere/source/kern_k_server_session.cpp b/libraries/libmesosphere/source/kern_k_server_session.cpp index 36159014c..e9da0fc6e 100644 --- a/libraries/libmesosphere/source/kern_k_server_session.cpp +++ b/libraries/libmesosphere/source/kern_k_server_session.cpp @@ -53,6 +53,10 @@ namespace ams::kern { this->msg_buffer_end = dst_address + sizeof(u32) * out_offset; this->msg_buffer_space_end = dst_address + msg_size; + /* NOTE: Nintendo calculates the receive list index here using the special header. */ + /* We pre-calculate it in the caller, and pass it as a parameter. */ + MESOSPHERE_UNUSED(dst_special_header); + const u32 *recv_list = dst_msg + dst_recv_list_idx; const auto entry_count = GetEntryCount(dst_header); @@ -494,6 +498,9 @@ namespace ams::kern { auto &dst_page_table = dst_process.GetPageTable(); auto &src_page_table = src_process.GetPageTable(); + /* NOTE: Session is used only for debugging, and so may go unused. */ + MESOSPHERE_UNUSED(session); + /* The receive list is initially not broken. */ recv_list_broken = false; @@ -711,7 +718,7 @@ namespace ams::kern { return ResultSuccess(); } - ALWAYS_INLINE Result ProcessSendMessagePointerDescriptors(int &offset, int &pointer_key, KProcessPageTable &dst_page_table, KProcessPageTable &src_page_table, const ipc::MessageBuffer &dst_msg, const ipc::MessageBuffer &src_msg, const ReceiveList &dst_recv_list, bool dst_user) { + ALWAYS_INLINE Result ProcessSendMessagePointerDescriptors(int &offset, int &pointer_key, KProcessPageTable &dst_page_table, const ipc::MessageBuffer &dst_msg, const ipc::MessageBuffer &src_msg, const ReceiveList &dst_recv_list, bool dst_user) { /* Get the offset at the start of processing. */ const int cur_offset = offset; @@ -758,6 +765,9 @@ namespace ams::kern { auto &dst_page_table = dst_process.GetPageTable(); auto &src_page_table = src_process.GetPageTable(); + /* NOTE: Session is used only for debugging, and so may go unused. */ + MESOSPHERE_UNUSED(session); + /* Determine the message buffers. */ u32 *dst_msg_ptr, *src_msg_ptr; bool dst_user, src_user; @@ -860,7 +870,7 @@ namespace ams::kern { /* Process any pointer buffers. */ for (auto i = 0; i < src_header.GetPointerCount(); ++i) { - R_TRY(ProcessSendMessagePointerDescriptors(offset, pointer_key, dst_page_table, src_page_table, dst_msg, src_msg, dst_recv_list, dst_user && dst_header.GetReceiveListCount() == ipc::MessageBuffer::MessageHeader::ReceiveListCountType_ToMessageBuffer)); + R_TRY(ProcessSendMessagePointerDescriptors(offset, pointer_key, dst_page_table, dst_msg, src_msg, dst_recv_list, dst_user && dst_header.GetReceiveListCount() == ipc::MessageBuffer::MessageHeader::ReceiveListCountType_ToMessageBuffer)); } /* Clear any map alias buffers. */ diff --git a/libraries/libmesosphere/source/kern_k_shared_memory.cpp b/libraries/libmesosphere/source/kern_k_shared_memory.cpp index 641e8c4f6..7756fef52 100644 --- a/libraries/libmesosphere/source/kern_k_shared_memory.cpp +++ b/libraries/libmesosphere/source/kern_k_shared_memory.cpp @@ -99,6 +99,7 @@ namespace ams::kern { Result KSharedMemory::Unmap(KProcessPageTable *table, KProcessAddress address, size_t size, KProcess *process) { MESOSPHERE_ASSERT_THIS(); + MESOSPHERE_UNUSED(process); /* Validate the size. */ R_UNLESS(this->page_group.GetNumPages() == util::DivideUp(size, PageSize), svc::ResultInvalidSize()); diff --git a/libraries/libmesosphere/source/kern_panic.cpp b/libraries/libmesosphere/source/kern_panic.cpp index fc4322e7d..92c765ad1 100644 --- a/libraries/libmesosphere/source/kern_panic.cpp +++ b/libraries/libmesosphere/source/kern_panic.cpp @@ -126,6 +126,8 @@ namespace ams::kern { MESOSPHERE_RELEASE_VLOG(format, vl); MESOSPHERE_RELEASE_LOG("\n"); va_end(vl); + #else + MESOSPHERE_UNUSED(file, line, format); #endif StopSystem(); diff --git a/libraries/libmesosphere/source/svc/kern_svc_kernel_debug.cpp b/libraries/libmesosphere/source/svc/kern_svc_kernel_debug.cpp index 8d18f46e6..b8ba28c6f 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_kernel_debug.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_kernel_debug.cpp @@ -26,6 +26,10 @@ namespace ams::kern::svc { { /* TODO: Implement Kernel Debugging. */ } + #else + { + MESOSPHERE_UNUSED(kern_debug_type, arg0, arg1, arg2); + } #endif } @@ -47,6 +51,10 @@ namespace ams::kern::svc { break; } } + #else + { + MESOSPHERE_UNUSED(kern_trace_state); + } #endif } diff --git a/libraries/libvapours/include/vapours/assert.hpp b/libraries/libvapours/include/vapours/assert.hpp index 8cd61bd61..5cf46d350 100644 --- a/libraries/libvapours/include/vapours/assert.hpp +++ b/libraries/libvapours/include/vapours/assert.hpp @@ -16,15 +16,6 @@ #pragma once #include -namespace ams::impl { - - template - constexpr ALWAYS_INLINE void UnusedImpl(ArgTypes... args) { - (static_cast(args), ...); - } - -} - namespace ams::diag { NORETURN NOINLINE void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) __attribute__((format(printf, 6, 7))); @@ -36,8 +27,6 @@ namespace ams::diag { } -#define AMS_UNUSED(...) ::ams::impl::UnusedImpl(__VA_ARGS__) - #ifdef AMS_ENABLE_DEBUG_PRINT #define AMS_CALL_ASSERT_FAIL_IMPL(cond, ...) ::ams::diag::AssertionFailureImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__) #define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__) diff --git a/libraries/libvapours/include/vapours/defines.hpp b/libraries/libvapours/include/vapours/defines.hpp index 124508e3c..82356f1a6 100644 --- a/libraries/libvapours/include/vapours/defines.hpp +++ b/libraries/libvapours/include/vapours/defines.hpp @@ -66,4 +66,19 @@ #define AMS_CURRENT_FUNCTION_NAME __FUNCTION__ +#if defined(__cplusplus) + +namespace ams::impl { + + template + constexpr ALWAYS_INLINE void UnusedImpl(ArgTypes &&... args) { + (static_cast(args), ...); + } + +} + +#endif + +#define AMS_UNUSED(...) ::ams::impl::UnusedImpl(__VA_ARGS__) + #define AMS_INFINITE_LOOP() do { __asm__ __volatile__("" ::: "memory"); } while (1) diff --git a/libraries/libvapours/include/vapours/results/results_common.hpp b/libraries/libvapours/include/vapours/results/results_common.hpp index 0e2fecc97..13d32aff6 100644 --- a/libraries/libvapours/include/vapours/results/results_common.hpp +++ b/libraries/libvapours/include/vapours/results/results_common.hpp @@ -83,7 +83,7 @@ namespace ams { constexpr Result(typename Base::BaseType v) : value(v) { static_assert(std::is_same::value); } constexpr ALWAYS_INLINE operator ResultSuccess() const; - NX_CONSTEXPR bool CanAccept(Result result) { return true; } + NX_CONSTEXPR bool CanAccept(Result) { return true; } constexpr ALWAYS_INLINE bool IsSuccess() const { return this->GetValue() == Base::SuccessValue; } constexpr ALWAYS_INLINE bool IsFailure() const { return !this->IsSuccess(); } diff --git a/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_kernel_svc_wrapper.hpp b/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_kernel_svc_wrapper.hpp index de6d25b32..e0f1998c2 100644 --- a/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_kernel_svc_wrapper.hpp +++ b/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_kernel_svc_wrapper.hpp @@ -353,7 +353,7 @@ namespace ams::svc::codegen::impl { }; template - static constexpr auto GetModifiedOperations(std::tuple ops) { + static constexpr auto GetModifiedOperations(std::tuple) { constexpr size_t ModifyRegister = [] { auto allocator = Allocator; return allocator.AllocateFirstFree(); @@ -535,7 +535,11 @@ namespace ams::svc::codegen::impl { GenerateCodeForMetaCode(); ON_SCOPE_EXIT { GenerateCodeForMetaCode(); }; + /* Cast the generated function to the generic funciton pointer type. */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-function-type" return reinterpret_cast(Function)(); + #pragma GCC diagnostic pop } #pragma GCC pop_options diff --git a/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_layout_conversion.hpp b/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_layout_conversion.hpp index 1b0189925..57584be41 100644 --- a/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_layout_conversion.hpp +++ b/libraries/libvapours/include/vapours/svc/codegen/impl/svc_codegen_impl_layout_conversion.hpp @@ -139,7 +139,7 @@ namespace ams::svc::codegen::impl { template static constexpr void GenerateCodeForPrepareForKernelProcedureToSvcInvocation(MetaCodeGenerator &mcg) { static_assert(Operation::Kind == OperationKind::PackAndUnpack); - /* ... */ + AMS_UNUSED(mcg); } template diff --git a/libraries/libvapours/include/vapours/svc/ipc/svc_message_buffer.hpp b/libraries/libvapours/include/vapours/svc/ipc/svc_message_buffer.hpp index af3b3cb5c..28c63dbd8 100644 --- a/libraries/libvapours/include/vapours/svc/ipc/svc_message_buffer.hpp +++ b/libraries/libvapours/include/vapours/svc/ipc/svc_message_buffer.hpp @@ -498,6 +498,7 @@ namespace ams::svc::ipc { } static constexpr ALWAYS_INLINE s32 GetSpecialDataIndex(const MessageHeader &hdr, const SpecialHeader &spc) { + AMS_UNUSED(hdr); return (MessageHeader::GetDataSize() / sizeof(util::BitPack32)) + (spc.GetHeaderSize() / sizeof(util::BitPack32)); } diff --git a/libraries/libvapours/include/vapours/timespan.hpp b/libraries/libvapours/include/vapours/timespan.hpp index 0cca06a84..a789a5710 100644 --- a/libraries/libvapours/include/vapours/timespan.hpp +++ b/libraries/libvapours/include/vapours/timespan.hpp @@ -61,7 +61,7 @@ namespace ams { private: TimeSpanType ts; public: - constexpr ALWAYS_INLINE TimeSpan(ZeroTag z = nullptr) : ts(TimeSpanType::FromNanoSeconds(0)) { /* ... */ } + constexpr ALWAYS_INLINE TimeSpan(ZeroTag z = nullptr) : ts(TimeSpanType::FromNanoSeconds(0)) { AMS_UNUSED(z); /* ... */ } constexpr ALWAYS_INLINE TimeSpan(const TimeSpanType &t) : ts(t) { /* ... */ } template diff --git a/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp b/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp index 511b289a7..486720f91 100644 --- a/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp +++ b/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp @@ -267,12 +267,14 @@ namespace ams::util { } void splice(const_iterator pos, IntrusiveListImpl &o, const_iterator first) { + AMS_UNUSED(o); const_iterator last(first); std::advance(last, 1); splice_impl(pos, first, last); } void splice(const_iterator pos, IntrusiveListImpl &o, const_iterator first, const_iterator last) { + AMS_UNUSED(o); splice_impl(pos, first, last); } diff --git a/libraries/libvapours/source/crypto/impl/crypto_xts_mode_impl.cpp b/libraries/libvapours/source/crypto/impl/crypto_xts_mode_impl.cpp index 86d022d71..90caa87ee 100644 --- a/libraries/libvapours/source/crypto/impl/crypto_xts_mode_impl.cpp +++ b/libraries/libvapours/source/crypto/impl/crypto_xts_mode_impl.cpp @@ -55,6 +55,7 @@ namespace ams::crypto::impl { size_t XtsModeImpl::FinalizeEncryption(void *dst, size_t dst_size) { AMS_ASSERT(this->state == State_Processing); + AMS_UNUSED(dst_size); u8 *dst_u8 = static_cast(dst); size_t processed = 0; @@ -80,6 +81,7 @@ namespace ams::crypto::impl { size_t XtsModeImpl::FinalizeDecryption(void *dst, size_t dst_size) { AMS_ASSERT(this->state == State_Processing); + AMS_UNUSED(dst_size); u8 *dst_u8 = static_cast(dst); size_t processed = 0; @@ -131,6 +133,8 @@ namespace ams::crypto::impl { } size_t XtsModeImpl::ProcessRemainingData(u8 *dst, const u8 *src, size_t size) { + AMS_UNUSED(dst); + std::memcpy(this->buffer, src, size); this->num_buffered = size; diff --git a/mesosphere/kernel/source/arch/arm64/init/kern_init_core.cpp b/mesosphere/kernel/source/arch/arm64/init/kern_init_core.cpp index 54ec9c055..995dad19d 100644 --- a/mesosphere/kernel/source/arch/arm64/init/kern_init_core.cpp +++ b/mesosphere/kernel/source/arch/arm64/init/kern_init_core.cpp @@ -357,6 +357,7 @@ namespace ams::kern::init { case ID: \ cpu::SetDbgWcr##ID##El1(__VA_ARGS__); \ cpu::SetDbgWvr##ID##El1(__VA_ARGS__); \ + [[fallthrough]]; #define MESOSPHERE_INITIALIZE_BREAKPOINT_CASE(ID, ...) \ case ID: \