diff --git a/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp b/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp index 322a3641..9332449d 100644 --- a/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp +++ b/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp @@ -58,7 +58,7 @@ namespace ams::kvdb { /* Getters. */ size_t GetLength() const { - return strnlen(this->buffer, N); + return util::Strnlen(this->buffer, N); } const char *Get() const { @@ -72,7 +72,7 @@ namespace ams::kvdb { /* Setters. */ void Set(const char *s) { /* Ensure string can fit in our buffer. */ - CheckLength(strnlen(s, N)); + CheckLength(util::Strnlen(s, N)); std::strncpy(this->buffer, s, N); this->buffer[N - 1] = 0; } @@ -88,7 +88,7 @@ namespace ams::kvdb { /* Append to existing. */ void Append(const char *s) { const size_t length = GetLength(); - CheckLength(length + strnlen(s, N)); + CheckLength(length + util::Strnlen(s, N)); std::strncat(this->buffer, s, N - length - 1); } @@ -137,7 +137,7 @@ namespace ams::kvdb { } bool EndsWith(const char *s) const { - const size_t suffix_length = strnlen(s, N); + const size_t suffix_length = util::Strnlen(s, N); const size_t length = GetLength(); return suffix_length <= length && EndsWith(s, length - suffix_length); } diff --git a/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp b/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp index c395fa7b..a0b8f994 100644 --- a/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp +++ b/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp @@ -26,7 +26,7 @@ namespace ams::tipc { constexpr inline u16 MethodId_CloseSession = 0xF; class ObjectManagerBase { - private: + protected: struct Entry { util::TypedStorage object; os::WaitableHolderType waitable_holder; diff --git a/libstratosphere/source/ams/ams_environment.cpp b/libstratosphere/source/ams/ams_environment.cpp index a42776b2..597a4627 100644 --- a/libstratosphere/source/ams/ams_environment.cpp +++ b/libstratosphere/source/ams/ams_environment.cpp @@ -117,7 +117,7 @@ namespace ams { StackFrame cur_frame; svc::lp64::MemoryInfo mem_info; svc::PageInfo page_info; - if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.perm & Perm_R) == Perm_R) { + if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.perm & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) { std::memcpy(&cur_frame, reinterpret_cast(cur_fp), sizeof(cur_frame)); } else { break; @@ -136,7 +136,7 @@ namespace ams { { svc::lp64::MemoryInfo mem_info; svc::PageInfo page_info; - if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), ams_ctx.sp)) && (mem_info.perm & Perm_R) == Perm_R) { + if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), ams_ctx.sp)) && (mem_info.perm & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) { size_t copy_size = std::min(FatalErrorContext::MaxStackDumpSize, static_cast(mem_info.addr + mem_info.size - ams_ctx.sp)); ams_ctx.stack_dump_size = copy_size; std::memcpy(ams_ctx.stack_dump, reinterpret_cast(ams_ctx.sp), copy_size); diff --git a/libstratosphere/source/fs/fs_bis.cpp b/libstratosphere/source/fs/fs_bis.cpp index 021913d7..da396e6a 100644 --- a/libstratosphere/source/fs/fs_bis.cpp +++ b/libstratosphere/source/fs/fs_bis.cpp @@ -29,7 +29,7 @@ namespace ams::fs { virtual Result GenerateCommonMountName(char *dst, size_t dst_size) override { /* Determine how much space we need. */ const char *bis_mount_name = GetBisMountName(this->id); - const size_t needed_size = strnlen(bis_mount_name, MountNameLengthMax) + 2; + const size_t needed_size = util::Strnlen(bis_mount_name, MountNameLengthMax) + 2; AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ diff --git a/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp b/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp index 1ef63f25..cb7dc3e9 100644 --- a/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp +++ b/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp @@ -219,10 +219,11 @@ namespace ams::htcs::client { sf::SharedPointer socket = nullptr; /* Find the socket. */ + s32 index; { std::scoped_lock lk(m_mutex); - if (auto index = this->Find(id, std::addressof(error_code)); index >= 0) { + if (index = this->Find(id, std::addressof(error_code)); index >= 0) { /* Get the socket's object. */ VirtualSocket *virt_socket = m_socket_list + index; socket = virt_socket->m_socket; diff --git a/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp b/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp index 358badce..86e598af 100644 --- a/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp +++ b/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp @@ -21,7 +21,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cBusAccessorManager : public IAllocator { - /* ... */ + public: + using IAllocator::IAllocator; }; } diff --git a/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp b/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp index e0a1e22d..ac6a2b54 100644 --- a/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp +++ b/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp @@ -20,7 +20,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cDevicePropertyManager : public IAllocator { - /* ... */ + public: + using IAllocator::IAllocator; }; } diff --git a/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp b/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp index 13cb57d0..41e51dfd 100644 --- a/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp +++ b/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp @@ -20,6 +20,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { template class IAllocator { + NON_COPYABLE(IAllocator); + NON_MOVEABLE(IAllocator); private: using T = typename ListType::value_type; private: diff --git a/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp b/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp index 11370ec5..db487e31 100644 --- a/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp +++ b/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp @@ -20,9 +20,9 @@ namespace ams::mem::impl { namespace { - os::Mutex g_virt_mem_enabled_lock(false); - bool g_virt_mem_enabled_detected; - bool g_virt_mem_enabled; + constinit os::SdkMutex g_virt_mem_enabled_lock; + constinit bool g_virt_mem_enabled_detected = false; + constinit bool g_virt_mem_enabled = false; void EnsureVirtualAddressMemoryDetected() { std::scoped_lock lk(g_virt_mem_enabled_lock); @@ -48,7 +48,8 @@ namespace ams::mem::impl { ALWAYS_INLINE os::MemoryPermission ConvertToOsPermission(Prot prot) { static_assert(static_cast(Prot_read) == static_cast(os::MemoryPermission_ReadOnly)); static_assert(static_cast(Prot_write) == static_cast(os::MemoryPermission_WriteOnly)); - return static_cast(prot & os::MemoryPermission_ReadWrite); + static_assert((util::ToUnderlying(Prot_read) | util::ToUnderlying(Prot_write)) == util::ToUnderlying(os::MemoryPermission_ReadWrite)); + return static_cast(prot & (Prot_read | Prot_write)); } } diff --git a/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp b/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp index eb30b7e9..2ab33856 100644 --- a/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp +++ b/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp @@ -477,7 +477,6 @@ namespace ams::pinmux::driver::board::nintendo::nx { u32 reg_address; u32 reg_mask; u32 reg_value; - u8 safe_func; const char *pad_name; private: bool IsValidRegisterAddress() const {