From e435f5636707b4dd40548896f1c37380dd06feec Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 17 Aug 2020 14:39:18 -0700 Subject: [PATCH] exo: build with -Wextra --- exosphere/loader_stub/source/secmon_loader_error.cpp | 2 ++ exosphere/program/source/boot/secmon_boot_setup.cpp | 3 +++ exosphere/program/source/secmon_map.cpp | 1 + exosphere/program/source/smc/secmon_smc_memory_access.cpp | 1 + .../program/source/smc/secmon_smc_power_management.cpp | 2 ++ exosphere/program/source/smc/secmon_smc_rsa.cpp | 1 + libraries/config/templates/exosphere.mk | 2 +- libraries/libexosphere/arm.mk | 2 +- libraries/libexosphere/arm64.mk | 2 +- .../include/exosphere/secmon/secmon_monitor_context.hpp | 6 ++++++ .../source/crypto/crypto_aes_impl_security_engine.cpp | 6 ++++++ libraries/libexosphere/source/i2c/i2c_api.cpp | 4 ++++ libraries/libvapours/include/vapours/assert.hpp | 2 +- 13 files changed, 30 insertions(+), 4 deletions(-) diff --git a/exosphere/loader_stub/source/secmon_loader_error.cpp b/exosphere/loader_stub/source/secmon_loader_error.cpp index 2f67b507f..4fc58c6f7 100644 --- a/exosphere/loader_stub/source/secmon_loader_error.cpp +++ b/exosphere/loader_stub/source/secmon_loader_error.cpp @@ -19,10 +19,12 @@ namespace ams::diag { NORETURN void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) { + AMS_UNUSED(file, line, func, expr, value, format); ams::secmon::loader::ErrorReboot(); } NORETURN void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) { + AMS_UNUSED(file, line, func, expr, value); ams::secmon::loader::ErrorReboot(); } diff --git a/exosphere/program/source/boot/secmon_boot_setup.cpp b/exosphere/program/source/boot/secmon_boot_setup.cpp index 9452d70fd..d7cde0b25 100644 --- a/exosphere/program/source/boot/secmon_boot_setup.cpp +++ b/exosphere/program/source/boot/secmon_boot_setup.cpp @@ -85,6 +85,8 @@ namespace ams::secmon::boot { if constexpr (false) { /* TODO: Consider implementing this as a reference. */ } + + AMS_UNUSED(is_prod); } /* NOTE: These are just latest-master-kek encrypted with BEK. */ @@ -406,6 +408,7 @@ namespace ams::secmon::boot { constexpr void UnmapDramImpl(u64 *l1, u64 *l2, u64 *l3) { /* Unmap the L1 entry corresponding to to the Dram entries. */ + AMS_UNUSED(l2, l3); InvalidateL1Entries(l1, MemoryRegionDram.GetAddress(), MemoryRegionDram.GetSize()); } diff --git a/exosphere/program/source/secmon_map.cpp b/exosphere/program/source/secmon_map.cpp index 96ccf84ed..6c604fdaa 100644 --- a/exosphere/program/source/secmon_map.cpp +++ b/exosphere/program/source/secmon_map.cpp @@ -41,6 +41,7 @@ namespace ams::secmon { constexpr void UnmapBootCodeImpl(u64 *l1, u64 *l2, u64 *l3, uintptr_t boot_code, size_t boot_code_size) { /* Unmap the L3 entries corresponding to the boot code. */ + AMS_UNUSED(l1, l2); InvalidateL3Entries(l3, boot_code, boot_code_size); } diff --git a/exosphere/program/source/smc/secmon_smc_memory_access.cpp b/exosphere/program/source/smc/secmon_smc_memory_access.cpp index dba249ccf..2f2c1ca2c 100644 --- a/exosphere/program/source/smc/secmon_smc_memory_access.cpp +++ b/exosphere/program/source/smc/secmon_smc_memory_access.cpp @@ -69,6 +69,7 @@ namespace ams::secmon::smc { SmcResult SmcWriteAddress(SmcArguments &args) { /* NOTE: This smc was deprecated in Atmosphère 0.13.0. */ + AMS_UNUSED(args); return SmcResult::NotImplemented; } diff --git a/exosphere/program/source/smc/secmon_smc_power_management.cpp b/exosphere/program/source/smc/secmon_smc_power_management.cpp index 1e8a90389..f83b76b0b 100644 --- a/exosphere/program/source/smc/secmon_smc_power_management.cpp +++ b/exosphere/program/source/smc/secmon_smc_power_management.cpp @@ -492,6 +492,8 @@ namespace ams::secmon::smc { } SmcResult SmcPowerOffCpu(SmcArguments &args) { + AMS_UNUSED(args); + /* Get the current core id. */ const auto core_id = hw::GetCurrentCoreId(); diff --git a/exosphere/program/source/smc/secmon_smc_rsa.cpp b/exosphere/program/source/smc/secmon_smc_rsa.cpp index 01104a503..460dccf3c 100644 --- a/exosphere/program/source/smc/secmon_smc_rsa.cpp +++ b/exosphere/program/source/smc/secmon_smc_rsa.cpp @@ -75,6 +75,7 @@ namespace ams::secmon::smc { u8 msg[se::RsaSize]; public: void Set(const void *m, size_t m_size) { + AMS_UNUSED(m_size); std::memcpy(this->msg, m, sizeof(this->msg)); } diff --git a/libraries/config/templates/exosphere.mk b/libraries/config/templates/exosphere.mk index 7025e615e..e2629d9f9 100644 --- a/libraries/config/templates/exosphere.mk +++ b/libraries/config/templates/exosphere.mk @@ -8,7 +8,7 @@ include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../common.mk #--------------------------------------------------------------------------------- ifeq ($(strip $(ATMOSPHERE_ARCH_NAME)),arm64) DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_EXOSPHERE -SETTINGS := $(ATMOSPHERE_SETTINGS) -mgeneral-regs-only -ffixed-x18 -Os -Werror -fno-non-call-exceptions +SETTINGS := $(ATMOSPHERE_SETTINGS) -mgeneral-regs-only -ffixed-x18 -Os -Wextra -Werror -fno-non-call-exceptions CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -fno-use-cxa-atexit ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) diff --git a/libraries/libexosphere/arm.mk b/libraries/libexosphere/arm.mk index 044c12891..f82386e0f 100644 --- a/libraries/libexosphere/arm.mk +++ b/libraries/libexosphere/arm.mk @@ -14,7 +14,7 @@ include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../config/common.mk #--------------------------------------------------------------------------------- DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_EXOSPHERE -SETTINGS := $(ATMOSPHERE_SETTINGS) -Os -Werror -flto -fno-non-call-exceptions +SETTINGS := $(ATMOSPHERE_SETTINGS) -Os -Wextra -Werror -flto -fno-non-call-exceptions CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -fno-use-cxa-atexit ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) diff --git a/libraries/libexosphere/arm64.mk b/libraries/libexosphere/arm64.mk index f20a5bcd2..3ce1165b1 100644 --- a/libraries/libexosphere/arm64.mk +++ b/libraries/libexosphere/arm64.mk @@ -14,7 +14,7 @@ include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../config/common.mk #--------------------------------------------------------------------------------- DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_EXOSPHERE -SETTINGS := $(ATMOSPHERE_SETTINGS) -mgeneral-regs-only -ffixed-x18 -Os -Werror -fno-non-call-exceptions +SETTINGS := $(ATMOSPHERE_SETTINGS) -mgeneral-regs-only -ffixed-x18 -Os -Wextra -Werror -fno-non-call-exceptions CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -fno-use-cxa-atexit ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) diff --git a/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp b/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp index 263ab28f8..568812c7c 100644 --- a/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp +++ b/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp @@ -89,7 +89,13 @@ namespace ams::secmon { constexpr inline const SecureMonitorConfiguration DefaultSecureMonitorConfiguration = { .target_firmware = ams::TargetFirmware_Current, + .key_generation = {}, + .hardware_type = {}, + .soc_type = {}, + .hardware_state = {}, + .pad_0B = {}, .flags = SecureMonitorConfigurationFlag_Default, + .reserved = {}, }; } 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 d71f72440..54fab167e 100644 --- a/libraries/libexosphere/source/crypto/crypto_aes_impl_security_engine.cpp +++ b/libraries/libexosphere/source/crypto/crypto_aes_impl_security_engine.cpp @@ -33,6 +33,8 @@ namespace ams::crypto::impl { template 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); /* Set the security engine keyslot. */ this->slot = *static_cast(key); @@ -50,9 +52,11 @@ namespace ams::crypto::impl { } else if constexpr (KeySize == 24) { /* Aes 192. */ /* TODO: se::EncryptAes192(dst, dst_size, this->slot, src, src_size); */ + AMS_UNUSED(dst, dst_size, src, src_size); } else if constexpr (KeySize == 32) { /* Aes 256. */ /* TODO: se::EncryptAes256(dst, dst_size, this->slot, src, src_size); */ + AMS_UNUSED(dst, dst_size, src, src_size); } else { /* Invalid key size. */ static_assert(!std::is_same, AesImpl>::value); @@ -71,9 +75,11 @@ namespace ams::crypto::impl { } else if constexpr (KeySize == 24) { /* Aes 192. */ /* TODO: se::DecryptAes192(dst, dst_size, this->slot, src, src_size); */ + AMS_UNUSED(dst, dst_size, src, src_size); } else if constexpr (KeySize == 32) { /* Aes 256. */ /* TODO: se::DecryptAes256(dst, dst_size, this->slot, src, src_size); */ + AMS_UNUSED(dst, dst_size, src, src_size); } else { /* Invalid key size. */ static_assert(!std::is_same, AesImpl>::value); diff --git a/libraries/libexosphere/source/i2c/i2c_api.cpp b/libraries/libexosphere/source/i2c/i2c_api.cpp index 108429768..baafacc93 100644 --- a/libraries/libexosphere/source/i2c/i2c_api.cpp +++ b/libraries/libexosphere/source/i2c/i2c_api.cpp @@ -88,6 +88,8 @@ namespace ams::i2c { } bool Write(uintptr_t base_address, Port port, int address, const void *src, size_t src_size, bool unused) { + AMS_UNUSED(port, unused); + /* Ensure we don't write too much. */ u32 data = 0; if (src_size > MaxTransferSize) { @@ -125,6 +127,8 @@ namespace ams::i2c { } bool Read(uintptr_t base_address, Port port, void *dst, size_t dst_size, int address, bool unused) { + AMS_UNUSED(port, unused); + /* Ensure we don't read too much. */ if (dst_size > MaxTransferSize) { return false; diff --git a/libraries/libvapours/include/vapours/assert.hpp b/libraries/libvapours/include/vapours/assert.hpp index 5cf46d350..d5034993c 100644 --- a/libraries/libvapours/include/vapours/assert.hpp +++ b/libraries/libvapours/include/vapours/assert.hpp @@ -32,7 +32,7 @@ namespace ams::diag { #define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, 0, ## __VA_ARGS__) #else #define AMS_CALL_ASSERT_FAIL_IMPL(cond, ...) ::ams::diag::AssertionFailureImpl("", 0, "", "", 0) -#define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl() +#define AMS_CALL_ABORT_IMPL(cond, ...) ::ams::diag::AbortImpl(); AMS_UNUSED(cond, ## __VA_ARGS__) #endif #ifdef AMS_ENABLE_ASSERTIONS