diff --git a/libraries/config/templates/stratosphere.mk b/libraries/config/templates/stratosphere.mk index fe7964907..aff1007b4 100644 --- a/libraries/config/templates/stratosphere.mk +++ b/libraries/config/templates/stratosphere.mk @@ -16,7 +16,7 @@ include $(DEVKITPRO)/libnx/switch_rules # options for code generation #--------------------------------------------------------------------------------- export DEFINES = $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_STRATOSPHERE -D_GNU_SOURCE -export SETTINGS = $(ATMOSPHERE_SETTINGS) -O2 +export SETTINGS = $(ATMOSPHERE_SETTINGS) -O2 -Wextra -Werror -Wno-missing-field-initializers export CFLAGS = $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) export CXXFLAGS = $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) export ASFLAGS = $(ATMOSPHERE_ASFLAGS) $(SETTINGS) $(DEFINES) diff --git a/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp b/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp index e6625b085..38eb78f26 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp @@ -132,7 +132,7 @@ namespace ams::fs::impl { /* Access log invocation lambdas. */ #define AMS_FS_IMPL_ACCESS_LOG_IMPL(__EXPR__, __HANDLE__, __ENABLED__, __NAME__, ...) \ - [&](const char *name) { \ + [&](const char *name) -> Result { \ if (!(__ENABLED__)) { \ return (__EXPR__); \ } else { \ @@ -145,7 +145,7 @@ namespace ams::fs::impl { }(__NAME__) #define AMS_FS_IMPL_ACCESS_LOG_WITH_PRIORITY_IMPL(__EXPR__, __PRIORITY__, __HANDLE__, __ENABLED__, __NAME__, ...) \ - [&](const char *name) { \ + [&](const char *name) -> Result { \ if (!(__ENABLED__)) { \ return (__EXPR__); \ } else { \ @@ -158,7 +158,7 @@ namespace ams::fs::impl { }(__NAME__) #define AMS_FS_IMPL_ACCESS_LOG_EXPLICIT_IMPL(__RESULT__, __START__, __END__, __HANDLE__, __ENABLED__, __NAME__, ...) \ - [&](const char *name) { \ + [&](const char *name) -> Result { \ if (!(__ENABLED__)) { \ return __RESULT__; \ } else { \ @@ -169,7 +169,7 @@ namespace ams::fs::impl { }(__NAME__) #define AMS_FS_IMPL_ACCESS_LOG_UNLESS_R_SUCCEEDED_IMPL(__EXPR__, __ENABLED__, __NAME__, ...) \ - [&](const char *name) { \ + [&](const char *name) -> Result { \ if (!(__ENABLED__)) { \ return (__EXPR__); \ } else { \ diff --git a/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp b/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp index d2b7489dc..6a4e0267f 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_user_filesystem.cpp @@ -244,22 +244,22 @@ namespace ams::fs { namespace { - Result CommitImpl(const char *path, const char *func_name) { - impl::FileSystemAccessor *accessor; - AMS_FS_R_TRY(AMS_FS_IMPL_ACCESS_LOG_UNLESS_R_SUCCEEDED(impl::Find(std::addressof(accessor), path), AMS_FS_IMPL_ACCESS_LOG_FORMAT_PATH, path)); + Result CommitImpl(const char *mount_name, const char *func_name) { + impl::FileSystemAccessor *accessor{}; + AMS_FS_R_TRY(AMS_FS_IMPL_ACCESS_LOG_UNLESS_R_SUCCEEDED(impl::Find(std::addressof(accessor), mount_name), AMS_FS_IMPL_ACCESS_LOG_FORMAT_MOUNT, mount_name)); - AMS_FS_R_TRY(AMS_FS_IMPL_ACCESS_LOG_FILESYSTEM_WITH_NAME(accessor->Commit(), nullptr, accessor, func_name, AMS_FS_IMPL_ACCESS_LOG_FORMAT_MOUNT, path)); + AMS_FS_R_TRY(AMS_FS_IMPL_ACCESS_LOG_FILESYSTEM_WITH_NAME(accessor->Commit(), nullptr, accessor, func_name, AMS_FS_IMPL_ACCESS_LOG_FORMAT_MOUNT, mount_name)); return ResultSuccess(); } } - Result Commit(const char *path) { - return CommitImpl(path, AMS_CURRENT_FUNCTION_NAME); + Result Commit(const char *mount_name) { + return CommitImpl(mount_name, AMS_CURRENT_FUNCTION_NAME); } - Result CommitSaveData(const char *path) { - return CommitImpl(path, AMS_CURRENT_FUNCTION_NAME); + Result CommitSaveData(const char *mount_name) { + return CommitImpl(mount_name, AMS_CURRENT_FUNCTION_NAME); } } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp b/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp index 58a6ed96d..88813fc37 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp @@ -31,7 +31,7 @@ namespace ams::fs::impl { } Result Find(FileSystemAccessor **out, const char *name) { - return g_mount_table.Find(out, name); + return g_mount_table.Find(out, name); } void Unregister(const char *name) { diff --git a/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp b/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp index 6d22f2746..6664724aa 100644 --- a/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp +++ b/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp @@ -31,7 +31,7 @@ namespace ams::htc::server { Result HtcServiceObject::GetEnvironmentVariable(sf::Out out_size, const sf::OutBuffer &out, const sf::InBuffer &name) { /* Get the variable. */ - size_t var_size; + size_t var_size = std::numeric_limits::max(); R_TRY(m_misc_impl.GetEnvironmentVariable(std::addressof(var_size), reinterpret_cast(out.GetPointer()), out.GetSize(), reinterpret_cast(name.GetPointer()), name.GetSize())); /* Check the output size. */ @@ -44,7 +44,7 @@ namespace ams::htc::server { Result HtcServiceObject::GetEnvironmentVariableLength(sf::Out out_size, const sf::InBuffer &name) { /* Get the variable. */ - size_t var_size; + size_t var_size = std::numeric_limits::max(); R_TRY(m_misc_impl.GetEnvironmentVariableLength(std::addressof(var_size), reinterpret_cast(name.GetPointer()), name.GetSize())); /* Check the output size. */ diff --git a/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_client.hpp b/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_client.hpp index 7adf7da55..dd9fafdff 100644 --- a/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_client.hpp +++ b/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_client.hpp @@ -94,8 +94,20 @@ namespace ams::htc::server::rpc { Result ReceiveBody(char *dst, size_t size); Result SendRequest(const char *src, size_t size); private: - template requires IsRpcTask - ALWAYS_INLINE Result BeginImpl(std::index_sequence, u32 *out_task_id, RpcTaskArgumentType... args) { + s32 GetTaskHandle(u32 task_id); + public: + void Wait(u32 task_id) { + os::WaitEvent(m_task_table.Get(task_id)->GetEvent()); + } + + os::NativeHandle DetachReadableHandle(u32 task_id) { + return os::DetachReadableHandleOfSystemEvent(m_task_table.Get(task_id)->GetSystemEvent()); + } + + void CancelBySocket(s32 handle); + + template requires (IsRpcTask && sizeof...(Args) == std::tuple_size>::value) + Result Begin(u32 *out_task_id, Args &&... args) { /* Lock ourselves. */ std::scoped_lock lk(m_mutex); @@ -117,7 +129,7 @@ namespace ams::htc::server::rpc { }; /* Set the task arguments. */ - R_TRY(task->SetArguments(args...)); + R_TRY(task->SetArguments(std::forward(args)...)); /* Clear the task's events. */ os::ClearEvent(std::addressof(m_receive_buffer_available_events[task_id])); @@ -138,8 +150,8 @@ namespace ams::htc::server::rpc { return ResultSuccess(); } - template requires IsRpcTask - ALWAYS_INLINE Result GetResultImpl(std::index_sequence, u32 task_id, RpcTaskResultType... args) { + template requires (IsRpcTask && sizeof...(Args) == std::tuple_size>::value) + Result GetResult(u32 task_id, Args &&... args) { /* Lock ourselves. */ std::scoped_lock lk(m_mutex); @@ -151,13 +163,13 @@ namespace ams::htc::server::rpc { R_UNLESS(task->GetTaskState() == RpcTaskState::Completed, htc::ResultTaskNotCompleted()); /* Get the task's result. */ - R_TRY(task->GetResult(args...)); + R_TRY(task->GetResult(std::forward(args)...)); return ResultSuccess(); } - template requires IsRpcTask - ALWAYS_INLINE Result EndImpl(std::index_sequence, u32 task_id, RpcTaskResultType... args) { + template requires (IsRpcTask && sizeof...(Args) == std::tuple_size>::value) + Result End(u32 task_id, Args &&... args) { /* Lock ourselves. */ std::scoped_lock lk(m_mutex); @@ -188,38 +200,11 @@ namespace ams::htc::server::rpc { } /* Get the task's result. */ - R_TRY(task->GetResult(args...)); + R_TRY(task->GetResult(std::forward(args)...)); return ResultSuccess(); } - s32 GetTaskHandle(u32 task_id); - public: - void Wait(u32 task_id) { - os::WaitEvent(m_task_table.Get(task_id)->GetEvent()); - } - - os::NativeHandle DetachReadableHandle(u32 task_id) { - return os::DetachReadableHandleOfSystemEvent(m_task_table.Get(task_id)->GetSystemEvent()); - } - - void CancelBySocket(s32 handle); - - template requires (IsRpcTask && sizeof...(Args) == std::tuple_size>::value) - Result Begin(u32 *out_task_id, Args &&... args) { - return this->BeginImpl(std::make_index_sequence>::value>(), out_task_id, std::forward(args)...); - } - - template requires (IsRpcTask && sizeof...(Args) == std::tuple_size>::value) - Result GetResult(u32 task_id, Args &&... args) { - return this->GetResultImpl(std::make_index_sequence>::value>(), task_id, std::forward(args)...); - } - - template requires (IsRpcTask && sizeof...(Args) == std::tuple_size>::value) - Result End(u32 task_id, Args &&... args) { - return this->EndImpl(std::make_index_sequence>::value>(), task_id, std::forward(args)...); - } - template requires IsRpcTask Result VerifyTaskIdWithHandle(u32 task_id, s32 handle) { /* Lock ourselves. */ diff --git a/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp b/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp index df9558137..3a60aec93 100644 --- a/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp +++ b/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.cpp @@ -159,20 +159,22 @@ namespace ams::htcs::impl { Result HtcsManagerImpl::StartSelect(u32 *out_task_id, os::NativeHandle *out_handle, Span read_handles, Span write_handles, Span exception_handles, s64 tv_sec, s64 tv_usec) { /* Start the select. */ u32 task_id; - os::NativeHandle handle; + os::NativeHandle handle = os::InvalidNativeHandle; const Result result = m_service.SelectStart(std::addressof(task_id), std::addressof(handle), read_handles, write_handles, exception_handles, tv_sec, tv_usec); /* Ensure our state ends up clean. */ if (htcs::ResultCancelled::Includes(result)) { - os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), handle, true, os::EventClearMode_ManualClear); - s32 err; bool empty; m_service.SelectEnd(std::addressof(err), std::addressof(empty), Span{}, Span{}, Span{}, task_id); - os::DestroySystemEvent(std::addressof(event)); - } else { + if (handle != os::InvalidNativeHandle) { + os::SystemEventType event; + os::AttachReadableHandleToSystemEvent(std::addressof(event), handle, true, os::EventClearMode_ManualClear); + + os::DestroySystemEvent(std::addressof(event)); + } + } else if (R_SUCCEEDED(result)) { *out_task_id = task_id; *out_handle = handle; } diff --git a/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp b/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp index 28e3648a1..fb1ec8ee1 100644 --- a/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp +++ b/libraries/libstratosphere/source/htcs/impl/htcs_service.cpp @@ -275,6 +275,7 @@ namespace ams::htcs::impl { Result HtcsService::SendSmallResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc) { AMS_UNUSED(desc); + /* Finish the task. */ htcs::SocketError err; R_TRY(m_rpc_client->End(task_id, std::addressof(err), out_size)); @@ -387,13 +388,13 @@ namespace ams::htcs::impl { u32 task_id; R_TRY(m_rpc_client->Begin(std::addressof(task_id), read_handles, write_handles, exception_handles, tv_sec, tv_usec)); - /* Check that the task isn't cancelled. */ - R_UNLESS(!m_rpc_client->IsCancelled(task_id), htcs::ResultCancelled()); - /* Detach the task. */ *out_task_id = task_id; *out_handle = m_rpc_client->DetachReadableHandle(task_id); + /* Check that the task isn't cancelled. */ + R_UNLESS(!m_rpc_client->IsCancelled(task_id), htcs::ResultCancelled()); + return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp index 8645ccd88..79948a7c5 100644 --- a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp +++ b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp @@ -131,7 +131,7 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Get the accept results. */ - s32 desc; + s32 desc = -1; manager->AcceptResults(out_err.GetPointer(), std::addressof(desc), out_address.GetPointer(), task_id, m_desc); /* If an error occurred, we're done. */ diff --git a/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp b/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp index 4c1b45ebb..ee965d37e 100644 --- a/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp +++ b/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp @@ -36,10 +36,12 @@ namespace ams::i2c { auto &header1 = cmd_list[this->current_index++]; /* Set the header. */ + header0 = {}; header0.Set(impl::CommandId_Receive); header0.Set((option & TransactionOption_StopCondition) != 0); header0.Set((option & TransactionOption_StartCondition) != 0); + header1 = {}; header1.Set(size); return ResultSuccess(); @@ -58,10 +60,12 @@ namespace ams::i2c { auto &header1 = cmd_list[this->current_index++]; /* Set the header. */ + header0 = {}; header0.Set(impl::CommandId_Send); header0.Set((option & TransactionOption_StopCondition) != 0); header0.Set((option & TransactionOption_StartCondition) != 0); + header1 = {}; header1.Set(size); /* Copy the data we're sending. */ @@ -84,9 +88,11 @@ namespace ams::i2c { auto &header1 = cmd_list[this->current_index++]; /* Set the header. */ + header0 = {}; header0.Set(impl::CommandId_Extension); header0.Set(impl::SubCommandId_Sleep); + header1 = {}; header1.Set(us); return ResultSuccess(); diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp index 6bc297b27..f9ef0d319 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp @@ -52,7 +52,7 @@ namespace ams::mem::impl::heap { this->use_virtual_memory = false; } else { /* We were not provided with a region to use as backing. */ - void *mem; + void *mem = nullptr; if (auto err = AllocateVirtualMemory(std::addressof(mem), size); err != 0) { return err; } diff --git a/stratosphere/LogManager/source/lm_main.cpp b/stratosphere/LogManager/source/lm_main.cpp index fc19ca502..298533b04 100644 --- a/stratosphere/LogManager/source/lm_main.cpp +++ b/stratosphere/LogManager/source/lm_main.cpp @@ -85,33 +85,37 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } @@ -131,6 +135,8 @@ namespace ams::lm::srv { int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Check thread priority. */ AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(LogManager, MainThread)); diff --git a/stratosphere/TioServer/source/tio_main.cpp b/stratosphere/TioServer/source/tio_main.cpp index ebe3660fd..7582d8f74 100644 --- a/stratosphere/TioServer/source/tio_main.cpp +++ b/stratosphere/TioServer/source/tio_main.cpp @@ -69,6 +69,8 @@ namespace ams::tio { } void DeallocateForFs(void *p, size_t size) { + AMS_UNUSED(size); + return lmem::FreeToExpHeap(g_fs_heap_handle, p); } @@ -117,38 +119,44 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(TioServer, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(TioServer, Main)); diff --git a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp index e42f7df8f..be4cc51da 100644 --- a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp @@ -145,7 +145,7 @@ namespace ams::mitm { } /* Initialization implementation */ - void InitializeThreadFunc(void *arg) { + void InitializeThreadFunc(void *) { /* Wait for the SD card to be ready. */ cfg::WaitSdCardInitialized(); diff --git a/stratosphere/ams_mitm/source/amsmitm_main.cpp b/stratosphere/ams_mitm/source/amsmitm_main.cpp index 7fcb5d215..8763e91ee 100644 --- a/stratosphere/ams_mitm/source/amsmitm_main.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_main.cpp @@ -104,18 +104,23 @@ void __appExit(void) { } void *__libnx_alloc(size_t size) { + AMS_UNUSED(size); AMS_ABORT("__libnx_alloc was called"); } void *__libnx_aligned_alloc(size_t alignment, size_t size) { + AMS_UNUSED(alignment, size); AMS_ABORT("__libnx_aligned_alloc was called"); } void __libnx_free(void *mem) { + AMS_UNUSED(mem); AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Register "ams" port, use up its session. */ { svc::Handle ams_port; diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_module.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_module.cpp index ff13b4316..11c968943 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_module.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpc_ams_module.cpp @@ -34,7 +34,7 @@ namespace ams::mitm::bpc_ams { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Create bpc:ams. */ { os::NativeHandle bpcams_h; diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp index 86d59bc91..ffbd3d5d1 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_module.cpp @@ -56,7 +56,7 @@ namespace ams::mitm::bpc { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Wait until initialization is complete. */ mitm::WaitInitialized(); diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp index 078507043..eadb2e6a8 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_module.cpp @@ -64,7 +64,7 @@ namespace ams::mitm::socket::resolver { os::ThreadType g_extra_threads[NumExtraThreads]; - void LoopServerThread(void *arg) { + void LoopServerThread(void *) { /* Loop forever, servicing our services. */ g_server_manager.LoopProcess(); } @@ -114,7 +114,7 @@ namespace ams::mitm::socket::resolver { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Wait until initialization is complete. */ mitm::WaitInitialized(); diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp index a006c24bc..eda793bbf 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp @@ -40,6 +40,8 @@ namespace ams::mitm::socket::resolver { } ssize_t SerializeRedirectedAddrInfo(u8 * const dst, size_t dst_size, const char *hostname, ams::socket::InAddrT redirect_addr, u16 redirect_port, const struct addrinfo *hint) { + AMS_UNUSED(hostname); + struct addrinfo ai = { .ai_flags = 0, .ai_family = AF_UNSPEC, @@ -85,6 +87,8 @@ namespace ams::mitm::socket::resolver { } Result ResolverImpl::GetHostByNameRequest(u32 cancel_handle, const sf::ClientProcessId &client_pid, bool use_nsd_resolve, const sf::InBuffer &name, sf::Out out_host_error, sf::Out out_errno, const sf::OutBuffer &out_hostent, sf::Out out_size) { + AMS_UNUSED(cancel_handle, client_pid, use_nsd_resolve); + const char *hostname = reinterpret_cast(name.GetPointer()); LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", this->client_info.program_id.value, hostname); @@ -105,6 +109,8 @@ namespace ams::mitm::socket::resolver { } Result ResolverImpl::GetAddrInfoRequest(u32 cancel_handle, const sf::ClientProcessId &client_pid, bool use_nsd_resolve, const sf::InBuffer &node, const sf::InBuffer &srv, const sf::InBuffer &serialized_hint, const sf::OutBuffer &out_addrinfo, sf::Out out_errno, sf::Out out_retval, sf::Out out_size) { + AMS_UNUSED(cancel_handle, client_pid, use_nsd_resolve); + const char *hostname = reinterpret_cast(node.GetPointer()); LogDebug("[%016lx]: GetAddrInfoRequest(%s, %s)\n", this->client_info.program_id.value, reinterpret_cast(node.GetPointer()), reinterpret_cast(srv.GetPointer())); @@ -142,6 +148,8 @@ namespace ams::mitm::socket::resolver { } Result ResolverImpl::GetHostByNameRequestWithOptions(const sf::ClientProcessId &client_pid, const sf::InAutoSelectBuffer &name, const sf::OutAutoSelectBuffer &out_hostent, sf::Out out_size, u32 options_version, const sf::InAutoSelectBuffer &options, u32 num_options, sf::Out out_host_error, sf::Out out_errno) { + AMS_UNUSED(client_pid, options_version, options, num_options); + const char *hostname = reinterpret_cast(name.GetPointer()); LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", this->client_info.program_id.value, hostname); @@ -162,6 +170,8 @@ namespace ams::mitm::socket::resolver { } Result ResolverImpl::GetAddrInfoRequestWithOptions(const sf::ClientProcessId &client_pid, const sf::InBuffer &node, const sf::InBuffer &srv, const sf::InBuffer &serialized_hint, const sf::OutAutoSelectBuffer &out_addrinfo, sf::Out out_size, sf::Out out_retval, u32 options_version, const sf::InAutoSelectBuffer &options, u32 num_options, sf::Out out_host_error, sf::Out out_errno) { + AMS_UNUSED(client_pid, options_version, options, num_options); + const char *hostname = reinterpret_cast(node.GetPointer()); LogDebug("[%016lx]: GetAddrInfoRequestWithOptions(%s, %s)\n", this->client_info.program_id.value, hostname, reinterpret_cast(srv.GetPointer())); diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.hpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.hpp index 82744d09c..a17d97b03 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.hpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.hpp @@ -35,6 +35,7 @@ namespace ams::mitm::socket::resolver { /* We will mitm: * - everything. */ + AMS_UNUSED(client_info); return true; } public: diff --git a/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer.cpp b/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer.cpp index c01ebfeb5..bb7d9845a 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer.cpp @@ -20,6 +20,9 @@ namespace ams::mitm::socket::resolver::serializer { ssize_t DNSSerializer::CheckToBufferArguments(const u8 *dst, size_t dst_size, size_t required, int error_id) { + /* TODO: Logging, using error_id */ + AMS_UNUSED(error_id); + if (dst == nullptr) { return -1; } else if (dst_size < required) { diff --git a/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer_impls_in_addr.cpp b/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer_impls_in_addr.cpp index 96ace840e..564b67f31 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer_impls_in_addr.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/serializer/serializer_impls_in_addr.cpp @@ -26,7 +26,7 @@ namespace ams::mitm::socket::resolver::serializer { concept IsInAddr = std::same_as || std::same_as; template requires IsInAddr - size_t SizeOfImpl(const T &in) { + size_t SizeOfImpl(const T &) { return sizeof(u32); } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 69932099e..5ee13215f 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -99,7 +99,7 @@ namespace ams::mitm::fs { return sf::CreateSharedObjectEmplaced(std::forward(args)...); } - Result OpenHblWebContentFileSystem(sf::Out> &out, ncm::ProgramId client_program_id, ncm::ProgramId program_id, FsFileSystemType filesystem_type) { + Result OpenHblWebContentFileSystem(sf::Out> &out, ncm::ProgramId program_id) { /* Verify eligibility. */ bool is_hbl; R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession()); @@ -122,7 +122,7 @@ namespace ams::mitm::fs { return ResultSuccess(); } - Result OpenProgramSpecificWebContentFileSystem(sf::Out> &out, ncm::ProgramId client_program_id, ncm::ProgramId program_id, FsFileSystemType filesystem_type, Service *fwd, const fssrv::sf::Path *path, bool with_id) { + Result OpenProgramSpecificWebContentFileSystem(sf::Out> &out, ncm::ProgramId program_id, FsFileSystemType filesystem_type, Service *fwd, const fssrv::sf::Path *path, bool with_id) { /* Directory must exist. */ { FsDir d; @@ -174,13 +174,13 @@ namespace ams::mitm::fs { R_UNLESS(filesystem_type == FsFileSystemType_ContentManual, sm::mitm::ResultShouldForwardToSession()); /* Try to mount the HBL web filesystem. If this succeeds then we're done. */ - R_UNLESS(R_FAILED(OpenHblWebContentFileSystem(out, client_program_id, program_id, filesystem_type)), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(OpenHblWebContentFileSystem(out, program_id))); /* If program specific override shouldn't be attempted, fall back. */ R_UNLESS(try_program_specific, sm::mitm::ResultShouldForwardToSession()); /* If we're not opening a HBL filesystem, just try to open a generic one. */ - return OpenProgramSpecificWebContentFileSystem(out, client_program_id, program_id, filesystem_type, fwd, path, with_id); + return OpenProgramSpecificWebContentFileSystem(out, program_id, filesystem_type, fwd, path, with_id); } } 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 e01a96d4a..9abf2122f 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 @@ -28,7 +28,7 @@ namespace ams::mitm::fs { os::MessageQueue g_req_mq(g_mq_storage + 0, 1); os::MessageQueue g_ack_mq(g_mq_storage + 1, 1); - void RomfsInitializerThreadFunction(void *arg) { + void RomfsInitializerThreadFunction(void *) { while (true) { uintptr_t storage_uptr = 0; g_req_mq.Receive(&storage_uptr); @@ -100,7 +100,6 @@ 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_SUCCEED_IF(size == 0); /* Ensure we're initialized. */ @@ -112,8 +111,8 @@ namespace ams::mitm::fs { const s64 virt_size = this->GetSize(); R_UNLESS(offset >= 0, fs::ResultInvalidOffset()); R_UNLESS(offset < virt_size, fs::ResultInvalidOffset()); - if (size_t(virt_size - offset) < size) { - size = size_t(virt_size - offset); + if (static_cast(virt_size - offset) < size) { + size = static_cast(virt_size - offset); } /* Find first source info via binary search. */ @@ -130,7 +129,7 @@ namespace ams::mitm::fs { if (offset < cur_source.virtual_offset + cur_source.size) { const s64 offset_within_source = offset - cur_source.virtual_offset; - const size_t cur_read_size = std::min(size - read_so_far, size_t(cur_source.size - offset_within_source)); + const size_t cur_read_size = std::min(size - read_so_far, static_cast(cur_source.size - offset_within_source)); switch (cur_source.source_type) { case romfs::DataSourceType::Storage: R_ABORT_UNLESS(this->storage_romfs->Read(cur_source.storage_source_info.offset + offset_within_source, cur_dst, cur_read_size)); @@ -167,7 +166,7 @@ namespace ams::mitm::fs { } else { /* Explicitly handle padding. */ const auto &next_source = *(++it); - const size_t padding_size = size_t(next_source.virtual_offset - offset); + const size_t padding_size = static_cast(next_source.virtual_offset - offset); std::memset(cur_dst, 0, padding_size); read_so_far += padding_size; @@ -194,6 +193,8 @@ namespace ams::mitm::fs { } Result LayeredRomfsStorage::OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { + AMS_UNUSED(offset, src, src_size); + switch (op_id) { case OperationId::Invalidate: case OperationId::QueryRange: diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp index 8874075d1..b4d73b36f 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp @@ -52,11 +52,13 @@ namespace ams::mitm::fs { virtual Result Write(s64 offset, const void *buffer, size_t size) override { /* TODO: Better result code? */ + AMS_UNUSED(offset, buffer, size); return ams::fs::ResultUnsupportedOperation(); } virtual Result SetSize(s64 size) override { /* TODO: Better result code? */ + AMS_UNUSED(size); return ams::fs::ResultUnsupportedOperation(); } }; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp index e050e307e..37256650d 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_module.cpp @@ -64,7 +64,7 @@ namespace ams::mitm::fs { os::ThreadType g_extra_threads[NumExtraThreads]; - void LoopServerThread(void *arg) { + void LoopServerThread(void *) { /* Loop forever, servicing our services. */ g_server_manager.LoopProcess(); } @@ -98,7 +98,7 @@ namespace ams::mitm::fs { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Create fs mitm. */ R_ABORT_UNLESS((g_server_manager.RegisterMitmServer(PortIndex_Mitm, MitmServiceName))); diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp index 4a9f450a5..27c52ef9e 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp @@ -28,45 +28,52 @@ namespace ams::mitm::fs { virtual ~ReadOnlyLayeredFileSystem() { /* ... */ } private: virtual Result DoCreateFile(const char *path, s64 size, int flags) override final { + AMS_UNUSED(path, size, flags); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoDeleteFile(const char *path) override final { + AMS_UNUSED(path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoCreateDirectory(const char *path) override final { + AMS_UNUSED(path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoDeleteDirectory(const char *path) override final { + AMS_UNUSED(path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoDeleteDirectoryRecursively(const char *path) override final { + AMS_UNUSED(path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoRenameFile(const char *old_path, const char *new_path) override final { + AMS_UNUSED(old_path, new_path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override final { + AMS_UNUSED(old_path, new_path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoGetEntryType(ams::fs::DirectoryEntryType *out, const char *path) override final { - R_UNLESS(R_FAILED(this->fs_1.GetEntryType(out, path)), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.GetEntryType(out, path))); return this->fs_2.GetEntryType(out, path); } virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, ams::fs::OpenMode mode) override final { - R_UNLESS(R_FAILED(this->fs_1.OpenFile(out_file, path, mode)), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.OpenFile(out_file, path, mode))); return this->fs_2.OpenFile(out_file, path, mode); } virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const char *path, ams::fs::OpenDirectoryMode mode) override final { - R_UNLESS(R_FAILED(this->fs_1.OpenDirectory(out_dir, path, mode)), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.OpenDirectory(out_dir, path, mode))); return this->fs_2.OpenDirectory(out_dir, path, mode); } @@ -75,19 +82,22 @@ namespace ams::mitm::fs { } virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) { + AMS_UNUSED(out, path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) { + AMS_UNUSED(out, path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoCleanDirectoryRecursively(const char *path) { + AMS_UNUSED(path); return ams::fs::ResultUnsupportedOperation(); } virtual Result DoGetFileTimeStampRaw(ams::fs::FileTimeStampRaw *out, const char *path) { - R_UNLESS(R_FAILED(this->fs_1.GetFileTimeStampRaw(out, path)), ResultSuccess()); + R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.GetFileTimeStampRaw(out, path))); return this->fs_2.GetFileTimeStampRaw(out, path); } }; diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp index 75de43d16..a9fb0c785 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_module.cpp @@ -61,7 +61,7 @@ namespace ams::mitm::ns { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Wait until initialization is complete. */ mitm::WaitInitialized(); diff --git a/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp b/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp index 1c12a65ea..72f6b419d 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setmitm_module.cpp @@ -64,7 +64,7 @@ namespace ams::mitm::settings { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Wait until initialization is complete. */ mitm::WaitInitialized(); diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp index 3bcf7faa5..d6db473c0 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp @@ -35,6 +35,7 @@ namespace ams::mitm::settings { /* We will mitm: * - everything, because we want to intercept all settings requests. */ + AMS_UNUSED(client_info); return true; } public: diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp index f8bef9f6b..2f2eedadb 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp @@ -45,7 +45,7 @@ namespace ams::mitm::sysupdater { } - void MitmModule::ThreadFunction(void *arg) { + void MitmModule::ThreadFunction(void *) { /* Wait until initialization is complete. */ mitm::WaitInitialized(); diff --git a/stratosphere/boot/source/api_overrides/pcv_clkrst_api_for_boot.board.nintendo_nx.cpp b/stratosphere/boot/source/api_overrides/pcv_clkrst_api_for_boot.board.nintendo_nx.cpp index 91aab6c2f..325b1f18d 100644 --- a/stratosphere/boot/source/api_overrides/pcv_clkrst_api_for_boot.board.nintendo_nx.cpp +++ b/stratosphere/boot/source/api_overrides/pcv_clkrst_api_for_boot.board.nintendo_nx.cpp @@ -111,6 +111,8 @@ namespace ams { } void SetClockRate(const ClkRstDefinition &def, u32 hz) { + AMS_UNUSED(hz); + /* Enable clock. */ reg::ReadWrite(g_clkrst_registers + def.clk_en_ofs, 1u << def.clk_en_index, 1u << def.clk_en_index); @@ -166,6 +168,7 @@ namespace ams { } void SetClockDisabled(ClkRstSession *session) { + AMS_UNUSED(session); AMS_ABORT("SetClockDisabled not implemented for boot system module"); } diff --git a/stratosphere/boot/source/boot_battery_driver.hpp b/stratosphere/boot/source/boot_battery_driver.hpp index 526439119..171f28c94 100644 --- a/stratosphere/boot/source/boot_battery_driver.hpp +++ b/stratosphere/boot/source/boot_battery_driver.hpp @@ -34,7 +34,8 @@ namespace ams::boot { bool present; R_TRY(powctl::IsBatteryPresent(std::addressof(present), this->battery_session)); - return present == false; + *out = !present; + return ResultSuccess(); } Result GetSocRep(float *out) { diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index b67acbf54..605117545 100644 --- a/stratosphere/boot/source/boot_main.cpp +++ b/stratosphere/boot/source/boot_main.cpp @@ -143,25 +143,25 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *__libnx_alloc(size_t size) { +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } @@ -177,6 +177,10 @@ void operator delete(void *p) { return Deallocate(p, 0); } +void operator delete(void *p, size_t size) { + return Deallocate(p, size); +} + void *operator new[](size_t size) { return Allocate(size); } @@ -189,8 +193,14 @@ void operator delete[](void *p) { return Deallocate(p, 0); } +void operator delete[](void *p, size_t size) { + return Deallocate(p, size); +} + int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(boot, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(boot, Main)); diff --git a/stratosphere/boot2/source/boot2_main.cpp b/stratosphere/boot2/source/boot2_main.cpp index 8b8aca664..61b7edc58 100644 --- a/stratosphere/boot2/source/boot2_main.cpp +++ b/stratosphere/boot2/source/boot2_main.cpp @@ -68,6 +68,7 @@ namespace { } void DeallocateForFs(void *p, size_t size) { + AMS_UNUSED(size); return lmem::FreeToExpHeap(g_fs_heap_handle, p); } @@ -111,38 +112,44 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(boot2, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(boot2, Main)); diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index 92bfb3d75..842886348 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -71,6 +71,7 @@ namespace { } void DeallocateForFs(void *p, size_t size) { + AMS_UNUSED(size); return lmem::FreeToExpHeap(g_fs_heap_handle, p); } @@ -100,33 +101,37 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } diff --git a/stratosphere/cs/source/cs_main.cpp b/stratosphere/cs/source/cs_main.cpp index 2a559a5c6..778e4d80e 100644 --- a/stratosphere/cs/source/cs_main.cpp +++ b/stratosphere/cs/source/cs_main.cpp @@ -76,6 +76,8 @@ namespace ams::cs { } void Deallocate(void *p, size_t size) { + AMS_UNUSED(size); + std::scoped_lock lk(g_heap_mutex); lmem::FreeToExpHeap(g_heap_handle, p); } @@ -131,33 +133,37 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } @@ -178,6 +184,8 @@ namespace ams::cs { int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + using namespace ams::cs; /* Set thread name. */ diff --git a/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp b/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp index 7801b2d7f..813a13e43 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_debug_process.cpp @@ -389,6 +389,7 @@ namespace ams::dmnt { } } else { /* TODO aarch32 branch decoding */ + AMS_UNUSED(ctx); } } diff --git a/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp b/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp index 51d83a0da..7030178d0 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_gdb_server_impl.cpp @@ -1096,6 +1096,7 @@ namespace ams::dmnt { reply = true; } } + break; case svc::DebugEvent_ExitThread: { AMS_DMNT2_GDB_LOG_DEBUG("ExitThread %lx\n", thread_id); diff --git a/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp b/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp index 04a2bdc25..e5ba23af0 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_hardware_breakpoint.cpp @@ -91,6 +91,8 @@ namespace ams::dmnt { } Result HardwareBreakPoint::Clear(DebugProcess *debug_process) { + AMS_UNUSED(debug_process); + Result result = svc::ResultInvalidArgument(); if (m_in_use) { AMS_DMNT2_GDB_LOG_DEBUG("HardwareBreakPoint::Clear %p 0x%lx\n", this, m_address); diff --git a/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp b/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp index ffc0413a0..aed443994 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_hardware_watchpoint.cpp @@ -93,6 +93,8 @@ namespace ams::dmnt { } Result WatchPoint::Clear(DebugProcess *debug_process) { + AMS_UNUSED(debug_process); + Result result = svc::ResultInvalidArgument(); if (m_in_use) { AMS_DMNT2_GDB_LOG_DEBUG("WatchPoint::Clear %p 0x%lx\n", this, m_address); diff --git a/stratosphere/dmnt.gen2/source/dmnt2_main.cpp b/stratosphere/dmnt.gen2/source/dmnt2_main.cpp index 48405749d..aac9adb83 100644 --- a/stratosphere/dmnt.gen2/source/dmnt2_main.cpp +++ b/stratosphere/dmnt.gen2/source/dmnt2_main.cpp @@ -95,38 +95,44 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* TODO ThreadName */ /* Initialize htcs. */ diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp index bbd43f4d1..538578669 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp @@ -81,6 +81,8 @@ namespace ams::dmnt::cheat::impl { } fs::WriteFile(this->debug_log_file, this->debug_log_offset, this->debug_log_format_buf, fmt_len, fs::WriteOption::Flush); + #else + AMS_UNUSED(format); #endif } diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index f66d69787..69ebf57c8 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -61,6 +61,7 @@ namespace { } void DeallocateForFs(void *p, size_t size) { + AMS_UNUSED(size); return lmem::FreeToExpHeap(g_fs_heap_handle, p); } @@ -126,7 +127,7 @@ namespace { constinit sf::UnmanagedServiceObject g_cheat_service; - void LoopServerThread(void *arg) { + void LoopServerThread(void *) { g_server_manager.LoopProcess(); } @@ -140,40 +141,48 @@ namespace { } + + namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(dmnt, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, Main)); diff --git a/stratosphere/eclct.stub/source/eclct_stub.cpp b/stratosphere/eclct.stub/source/eclct_stub.cpp index 24b44d0f8..bb4cec567 100644 --- a/stratosphere/eclct.stub/source/eclct_stub.cpp +++ b/stratosphere/eclct.stub/source/eclct_stub.cpp @@ -62,6 +62,7 @@ void __appExit(void) { int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); return 0; } diff --git a/stratosphere/erpt/source/erpt_main.cpp b/stratosphere/erpt/source/erpt_main.cpp index 1a7c0528a..0b65bd52d 100644 --- a/stratosphere/erpt/source/erpt_main.cpp +++ b/stratosphere/erpt/source/erpt_main.cpp @@ -115,38 +115,44 @@ namespace ams::erpt { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(erpt, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(erpt, Main)); diff --git a/stratosphere/fatal/source/fatal_debug.cpp b/stratosphere/fatal/source/fatal_debug.cpp index a29d6a1c0..d4c1ac105 100644 --- a/stratosphere/fatal/source/fatal_debug.cpp +++ b/stratosphere/fatal/source/fatal_debug.cpp @@ -143,6 +143,7 @@ namespace ams::fatal::srv { if (request.meta.num_send_buffers != 1) { return false; } + break; default: return false; } diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 9dd9c3930..7821a3417 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -60,6 +60,7 @@ namespace ams::fatal { } void DeallocateForFs(void *p, size_t size) { + AMS_UNUSED(size); return lmem::FreeToExpHeap(g_fs_heap_handle, p); } @@ -162,38 +163,44 @@ namespace { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Disable auto-abort in fs operations. */ fs::SetEnabledAutoAbort(false); diff --git a/stratosphere/htc/source/htc_main.cpp b/stratosphere/htc/source/htc_main.cpp index 0b4057424..abd9c54ff 100644 --- a/stratosphere/htc/source/htc_main.cpp +++ b/stratosphere/htc/source/htc_main.cpp @@ -67,6 +67,8 @@ namespace ams::htc { } void Deallocate(void *p, size_t size) { + AMS_UNUSED(size); + return lmem::FreeToExpHeap(g_heap_handle, p); } @@ -117,48 +119,51 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } - void *MallocForRapidJson(size_t size) { + void *MallocForRapidJson(size_t) { AMS_ABORT("ams::MallocForRapidJson was called"); } - void *ReallocForRapidJson(void *ptr, size_t size) { + void *ReallocForRapidJson(void *, size_t) { AMS_ABORT("ams::ReallocForRapidJson was called"); } void FreeForRapidJson(void *ptr) { - if (ptr == nullptr) { - return; + if (ptr != nullptr) { + AMS_ABORT("ams::FreeForRapidJson was called"); } - AMS_ABORT("ams::FreeForRapidJson was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } @@ -211,15 +216,15 @@ namespace ams::htc { } } - void HtcIpcThreadFunction(void *arg) { + void HtcIpcThreadFunction(void *) { htc::server::LoopHtcmiscServer(); } - void HtcfsIpcThreadFunction(void *arg) { + void HtcfsIpcThreadFunction(void *) { htcfs::LoopHipcServer(); } - void HtcsIpcThreadFunction(void *arg) { + void HtcsIpcThreadFunction(void *) { htcs::server::LoopHipcServer(); } @@ -244,6 +249,8 @@ namespace ams::htclow::driver { int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(htc, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(htc, Main)); diff --git a/stratosphere/jpegdec/source/jpegdec_main.cpp b/stratosphere/jpegdec/source/jpegdec_main.cpp index 00f37c80e..762a4d276 100644 --- a/stratosphere/jpegdec/source/jpegdec_main.cpp +++ b/stratosphere/jpegdec/source/jpegdec_main.cpp @@ -67,6 +67,8 @@ void __appExit(void) { int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(jpegdec, Main)); diff --git a/stratosphere/loader/source/ldr_loader_service.cpp b/stratosphere/loader/source/ldr_loader_service.cpp index bfeaa96e7..6ca2806e3 100644 --- a/stratosphere/loader/source/ldr_loader_service.cpp +++ b/stratosphere/loader/source/ldr_loader_service.cpp @@ -34,10 +34,12 @@ namespace ams::ldr { R_TRY(ldr::GetProgramInfo(out, &status, loc)); if (loc.storage_id != static_cast(ncm::StorageId::None) && loc.program_id != out->program_id) { - char path[FS_MAX_PATH]; + char path[fs::EntryNameLengthMax]; const ncm::ProgramLocation new_loc = ncm::ProgramLocation::Make(out->program_id, static_cast(loc.storage_id)); R_TRY(ResolveContentPath(path, loc)); + path[sizeof(path) - 1] = '\x00'; + R_TRY(RedirectContentPath(path, new_loc)); const auto arg_info = args::Get(loc.program_id); @@ -59,13 +61,16 @@ namespace ams::ldr { Result LoaderService::CreateProcess(sf::OutMoveHandle out, PinId id, u32 flags, sf::CopyHandle &&reslimit_h) { ncm::ProgramLocation loc; cfg::OverrideStatus override_status; - char path[FS_MAX_PATH]; + char path[fs::EntryNameLengthMax]; /* Get location and override status. */ R_TRY(ldr::ro::GetProgramLocationAndStatus(&loc, &override_status, id)); if (loc.storage_id != static_cast(ncm::StorageId::None)) { R_TRY(ResolveContentPath(path, loc)); + path[sizeof(path) - 1] = '\x00'; + } else { + path[0] = '\x00'; } /* Create the process. */ diff --git a/stratosphere/loader/source/ldr_main.cpp b/stratosphere/loader/source/ldr_main.cpp index 2f656bb69..f0c67c4d1 100644 --- a/stratosphere/loader/source/ldr_main.cpp +++ b/stratosphere/loader/source/ldr_main.cpp @@ -60,6 +60,7 @@ namespace ams::ldr { } void Deallocate(void *p, size_t size) { + AMS_UNUSED(size); return lmem::FreeToExpHeap(g_server_heap_handle, p); } @@ -159,11 +160,11 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } @@ -177,20 +178,26 @@ void operator delete(void *p) { return ldr::Deallocate(p, 0); } -void *__libnx_alloc(size_t size) { +void operator delete(void *p, size_t size) { + return ldr::Deallocate(p, size); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Disable auto-abort in fs operations. */ fs::SetEnabledAutoAbort(false); diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index 744098ac9..6283ec722 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -123,6 +123,8 @@ namespace ams::ldr { R_UNLESS(entries[i].version <= version, ResultInvalidVersion()); } } +#else + AMS_UNUSED(program_id, version); #endif return ResultSuccess(); } @@ -662,6 +664,7 @@ namespace ams::ldr { { /* Mount code. */ + AMS_UNUSED(path); ScopedCodeMount mount(loc, override_status); R_TRY(mount.GetResult()); diff --git a/stratosphere/ncm/source/ncm_main.cpp b/stratosphere/ncm/source/ncm_main.cpp index efef4f9e6..a026962cd 100644 --- a/stratosphere/ncm/source/ncm_main.cpp +++ b/stratosphere/ncm/source/ncm_main.cpp @@ -103,25 +103,25 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *__libnx_alloc(size_t size) { +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } @@ -137,6 +137,10 @@ void operator delete(void *p) { return Deallocate(p, 0); } +void operator delete(void *p, size_t size) { + return Deallocate(p, size); +} + void *operator new[](size_t size) { return Allocate(size); } @@ -149,6 +153,11 @@ void operator delete[](void *p) { return Deallocate(p, 0); } +void operator delete[](void *p, size_t size) { + return Deallocate(p, size); +} + + namespace { struct ContentManagerServerOptions { @@ -265,6 +274,8 @@ namespace { int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Disable auto-abort in fs operations. */ fs::SetEnabledAutoAbort(false); diff --git a/stratosphere/pgl/source/pgl_main.cpp b/stratosphere/pgl/source/pgl_main.cpp index a8ab934e7..c7d6aeb05 100644 --- a/stratosphere/pgl/source/pgl_main.cpp +++ b/stratosphere/pgl/source/pgl_main.cpp @@ -87,11 +87,11 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } @@ -105,20 +105,26 @@ void operator delete(void *p) { return pgl::srv::Deallocate(p, 0); } -void *__libnx_alloc(size_t size) { +void operator delete(void *p, size_t size) { + return pgl::srv::Deallocate(p, size); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Disable auto-abort in fs operations. */ fs::SetEnabledAutoAbort(false); diff --git a/stratosphere/pm/source/impl/pm_process_manager.cpp b/stratosphere/pm/source/impl/pm_process_manager.cpp index 6a88e654d..2d58009d9 100644 --- a/stratosphere/pm/source/impl/pm_process_manager.cpp +++ b/stratosphere/pm/source/impl/pm_process_manager.cpp @@ -118,7 +118,7 @@ namespace ams::pm::impl { }; /* Process Tracking globals. */ - void ProcessTrackingMain(void *arg); + void ProcessTrackingMain(void *); constinit os::ThreadType g_process_track_thread; alignas(os::ThreadStackAlignment) constinit u8 g_process_track_thread_stack[16_KB]; @@ -154,7 +154,7 @@ namespace ams::pm::impl { void OnProcessSignaled(ProcessListAccessor &list, ProcessInfo *process_info); /* Helpers. */ - void ProcessTrackingMain(void *arg) { + void ProcessTrackingMain(void *) { /* This is the main loop of the process tracking thread. */ /* Setup multi wait/holders. */ @@ -552,6 +552,7 @@ namespace ams::pm::impl { /* Information Getters. */ Result GetModuleIdList(u32 *out_count, u8 *out_buf, size_t max_out_count, u64 unused) { /* This function was always stubbed... */ + AMS_UNUSED(out_buf, max_out_count, unused); *out_count = 0; return ResultSuccess(); } @@ -560,11 +561,19 @@ namespace ams::pm::impl { ProcessListAccessor list(g_process_list); size_t count = 0; - for (auto &process : *list) { - if (process.HasExceptionWaitingAttach()) { - out_process_ids[count++] = process.GetProcessId(); + + if (max_out_count > 0) { + for (auto &process : *list) { + if (process.HasExceptionWaitingAttach()) { + out_process_ids[count++] = process.GetProcessId(); + + if (count >= max_out_count) { + break; + } + } } } + *out_count = static_cast(count); return ResultSuccess(); } diff --git a/stratosphere/pm/source/pm_main.cpp b/stratosphere/pm/source/pm_main.cpp index 56c325cd0..005a6d50e 100644 --- a/stratosphere/pm/source/pm_main.cpp +++ b/stratosphere/pm/source/pm_main.cpp @@ -218,28 +218,46 @@ namespace { } -void *operator new(size_t size) { +namespace ams { + + void *Malloc(size_t) { + AMS_ABORT("ams::Malloc was called"); + } + + void Free(void *) { + AMS_ABORT("ams::Free was called"); + } + +} + +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(pm, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(pm, Main)); diff --git a/stratosphere/ro/source/ro_main.cpp b/stratosphere/ro/source/ro_main.cpp index c51f51470..f3d8b3daa 100644 --- a/stratosphere/ro/source/ro_main.cpp +++ b/stratosphere/ro/source/ro_main.cpp @@ -95,6 +95,8 @@ namespace ams::ro { } void Deallocate(void *p, size_t size) { + AMS_UNUSED(size); + return lmem::FreeToExpHeap(g_server_heap_handle, p); } @@ -158,38 +160,44 @@ void __appExit(void) { namespace ams { - void *Malloc(size_t size) { + void *Malloc(size_t) { AMS_ABORT("ams::Malloc was called"); } - void Free(void *ptr) { + void Free(void *) { AMS_ABORT("ams::Free was called"); } } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(ro, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(ro, Main)); diff --git a/stratosphere/sm/source/sm_main.cpp b/stratosphere/sm/source/sm_main.cpp index e00475cbf..279944005 100644 --- a/stratosphere/sm/source/sm_main.cpp +++ b/stratosphere/sm/source/sm_main.cpp @@ -52,6 +52,7 @@ namespace { namespace ams { void NORETURN Exit(int rc) { + AMS_UNUSED(rc); AMS_ABORT("Exit called by immortal process"); } @@ -92,28 +93,34 @@ void __appExit(void) { /* Nothing to clean up, because we're sm. */ } -void *operator new(size_t size) { +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(sm, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(sm, Main)); diff --git a/stratosphere/sm/source/sm_user_service.cpp b/stratosphere/sm/source/sm_user_service.cpp index 87be2c90a..786e0b335 100644 --- a/stratosphere/sm/source/sm_user_service.cpp +++ b/stratosphere/sm/source/sm_user_service.cpp @@ -52,6 +52,8 @@ namespace ams::sm { } Result UserService::DetachClient(const tipc::ClientProcessId client_process_id) { + AMS_UNUSED(client_process_id); + m_initialized = false; return ResultSuccess(); } diff --git a/stratosphere/spl/source/spl_main.cpp b/stratosphere/spl/source/spl_main.cpp index 6f5a0948e..4676d13a8 100644 --- a/stratosphere/spl/source/spl_main.cpp +++ b/stratosphere/spl/source/spl_main.cpp @@ -175,28 +175,46 @@ namespace { } -void *operator new(size_t size) { +namespace ams { + + void *Malloc(size_t) { + AMS_ABORT("ams::Malloc was called"); + } + + void Free(void *) { + AMS_ABORT("ams::Free was called"); + } + +} + +void *operator new(size_t) { AMS_ABORT("operator new(size_t) was called"); } -void operator delete(void *p) { +void operator delete(void *) { AMS_ABORT("operator delete(void *) was called"); } -void *__libnx_alloc(size_t size) { +void operator delete(void *, size_t) { + AMS_ABORT("operator delete(void *, size_t) was called"); +} + +void *__libnx_alloc(size_t) { AMS_ABORT("__libnx_alloc was called"); } -void *__libnx_aligned_alloc(size_t alignment, size_t size) { +void *__libnx_aligned_alloc(size_t, size_t) { AMS_ABORT("__libnx_aligned_alloc was called"); } -void __libnx_free(void *mem) { +void __libnx_free(void *) { AMS_ABORT("__libnx_free was called"); } int main(int argc, char **argv) { + AMS_UNUSED(argc, argv); + /* Set thread name. */ os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(spl, Main)); AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(spl, Main));