From a89c5dd5d7291ea12b07a4951d4a09c3f12592db Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 22 Mar 2022 14:02:14 -0700 Subject: [PATCH] ncm: hot take, uninitialized data bad --- .../lr_add_on_content_location_resolver.hpp | 2 +- .../stratosphere/lr/lr_location_resolver.hpp | 2 +- .../lr/lr_registered_location_resolver.hpp | 2 +- .../ncm/ncm_content_manager_impl.hpp | 4 ++-- .../ncm/ncm_content_meta_database.hpp | 2 +- .../stratosphere/ncm/ncm_content_storage.hpp | 2 +- .../ncm/ncm_install_task_base.hpp | 24 +++++++++---------- .../ncm/ncm_install_task_data.hpp | 6 ++--- .../ncm/ncm_package_install_task.hpp | 2 +- .../ncm/ncm_package_install_task_base.hpp | 4 ++-- .../ncm/ncm_package_system_update_task.hpp | 8 +++---- .../stratosphere/ncm/ncm_rights_id_cache.hpp | 2 +- .../lr/lr_content_location_resolver_impl.hpp | 2 +- .../lr_registered_location_resolver_impl.hpp | 2 +- .../ncm_content_meta_database_impl_base.hpp | 2 +- .../ncm/ncm_content_storage_impl_base.hpp | 2 +- .../source/ncm/ncm_placeholder_accessor.hpp | 2 +- .../ncm_submission_package_install_task.cpp | 2 +- 18 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp index 060a77f79..0e309c735 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp @@ -25,7 +25,7 @@ namespace ams::lr { private: sf::SharedPointer m_interface; public: - AddOnContentLocationResolver() { /* ... */ } + AddOnContentLocationResolver() : m_interface(nullptr) { /* ... */ } explicit AddOnContentLocationResolver(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } AddOnContentLocationResolver(AddOnContentLocationResolver &&rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp index e6790dd3d..cc1b7f370 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp @@ -25,7 +25,7 @@ namespace ams::lr { private: sf::SharedPointer m_interface; public: - LocationResolver() { /* ... */ } + LocationResolver() : m_interface(nullptr) { /* ... */ } explicit LocationResolver(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } LocationResolver(LocationResolver &&rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp index 7369c45db..6ef018956 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp @@ -25,7 +25,7 @@ namespace ams::lr { private: sf::SharedPointer m_interface; public: - RegisteredLocationResolver() { /* ... */ } + RegisteredLocationResolver() : m_interface(nullptr) { /* ... */ } explicit RegisteredLocationResolver(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } RegisteredLocationResolver(RegisteredLocationResolver &&rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index 01026705d..748202a79 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -84,7 +84,7 @@ namespace ams::ncm { fs::ContentStorageId content_storage_id; sf::SharedPointer content_storage; - ContentStorageRoot() { /* ... */ } + ContentStorageRoot() : mount_name(), path(), storage_id(), content_storage_id(), content_storage() { /* ... */ } }; struct ContentMetaDatabaseRoot { @@ -100,7 +100,7 @@ namespace ams::ncm { ContentMetaMemoryResource *memory_resource; u32 max_content_metas; - ContentMetaDatabaseRoot() { /* ... */ } + ContentMetaDatabaseRoot() : mount_name(), path(), storage_id(), info(), content_meta_database(), kvs(util::nullopt), memory_resource(), max_content_metas() { /* ... */ } }; private: os::SdkRecursiveMutex m_mutex; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp index 32393f746..8bfb99e4b 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp @@ -28,7 +28,7 @@ namespace ams::ncm { private: sf::SharedPointer m_interface; public: - ContentMetaDatabase() { /* ... */ } + ContentMetaDatabase() : m_interface(nullptr) { /* ... */ } explicit ContentMetaDatabase(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } ContentMetaDatabase(ContentMetaDatabase &&rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp index 43d207c7c..9adf42278 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp @@ -23,7 +23,7 @@ namespace ams::ncm { private: sf::SharedPointer m_interface; public: - ContentStorage() { /* ... */ } + ContentStorage() : m_interface(nullptr) { /* ... */ } explicit ContentStorage(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } ContentStorage(ContentStorage &&rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp index 4689f6c8e..2ce0b2e3a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp @@ -82,18 +82,18 @@ namespace ams::ncm { NON_COPYABLE(InstallTaskBase); NON_MOVEABLE(InstallTaskBase); private: - crypto::Sha256Generator m_sha256_generator; - StorageId m_install_storage; - InstallTaskDataBase *m_data; - InstallProgress m_progress; - os::SdkMutex m_progress_mutex; - u32 m_config; - os::SdkMutex m_cancel_mutex; - bool m_cancel_requested; - InstallThroughput m_throughput; - TimeSpan m_throughput_start_time; - os::SdkMutex m_throughput_mutex; - FirmwareVariationId m_firmware_variation_id; + crypto::Sha256Generator m_sha256_generator{}; + StorageId m_install_storage{}; + InstallTaskDataBase *m_data{}; + InstallProgress m_progress{}; + os::SdkMutex m_progress_mutex{}; + u32 m_config{}; + os::SdkMutex m_cancel_mutex{}; + bool m_cancel_requested{}; + InstallThroughput m_throughput{}; + TimeSpan m_throughput_start_time{}; + os::SdkMutex m_throughput_mutex{}; + FirmwareVariationId m_firmware_variation_id{}; private: ALWAYS_INLINE Result SetLastResultOnFailure(Result result) { if (R_FAILED(result)) { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp index a016257ce..950c65a77 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp @@ -64,7 +64,7 @@ namespace ams::ncm { Result m_last_result; SystemUpdateTaskApplyInfo m_system_update_task_apply_info; public: - MemoryInstallTaskData() : m_state(InstallProgressState::NotPrepared), m_last_result(ResultSuccess()) { /* ... */ }; + MemoryInstallTaskData() : m_data_list(), m_state(InstallProgressState::NotPrepared), m_last_result(ResultSuccess()), m_system_update_task_apply_info() { /* ... */ }; ~MemoryInstallTaskData() { this->Cleanup(); } @@ -104,8 +104,8 @@ namespace ams::ncm { static_assert(sizeof(EntryInfo) == 0x10); private: - Header m_header; - char m_path[64]; + Header m_header{}; + char m_path[64]{}; private: static constexpr Header MakeInitialHeader(s32 max_entries) { return { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp index b69e26908..9aef51639 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp @@ -20,7 +20,7 @@ namespace ams::ncm { class PackageInstallTask : public PackageInstallTaskBase { private: - MemoryInstallTaskData m_data; + MemoryInstallTaskData m_data{}; public: Result Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket); protected: diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp index 9434c924b..72341bec4 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp @@ -24,8 +24,8 @@ namespace ams::ncm { using PackagePath = kvdb::BoundedString<256>; private: PackagePath m_package_root; - void *m_buffer; - size_t m_buffer_size; + void *m_buffer{}; + size_t m_buffer_size{}; public: PackageInstallTaskBase() : m_package_root() { /* ... */ } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp index c03c4234a..568383c8a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp @@ -22,10 +22,10 @@ namespace ams::ncm { private: using PackagePath = kvdb::BoundedString<0x100>; private: - PackagePath m_context_path; - FileInstallTaskData m_data; - ContentMetaDatabase m_package_db; - bool m_gamecard_content_meta_database_active; + PackagePath m_context_path{}; + FileInstallTaskData m_data{}; + ContentMetaDatabase m_package_db{}; + bool m_gamecard_content_meta_database_active{}; public: ~PackageSystemUpdateTask(); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp index 7cdac9693..ca6e1ab6a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp @@ -37,7 +37,7 @@ namespace ams::ncm { u64 m_counter; os::SdkMutex m_mutex; public: - RightsIdCache() : m_mutex() { + RightsIdCache() : m_entries(), m_counter(2), m_mutex() { this->Invalidate(); } diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp index 9f02fe998..b0d908bdb 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp @@ -27,7 +27,7 @@ namespace ams::lr { ncm::ContentMetaDatabase m_content_meta_database; ncm::ContentStorage m_content_storage; public: - ContentLocationResolverImpl(ncm::StorageId storage_id) : m_storage_id(storage_id) { /* ... */ } + ContentLocationResolverImpl(ncm::StorageId storage_id) : m_storage_id(storage_id), m_content_meta_database(), m_content_storage() { /* ... */ } ~ContentLocationResolverImpl(); private: diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp index bfd3cb186..bb3c0841c 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp @@ -45,7 +45,7 @@ namespace ams::lr { void ClearRedirections(u32 flags = RedirectionFlags_None); Result RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids); public: - RegisteredLocationResolverImpl() : m_registered_program_locations(GetMaxRegisteredLocations()), m_registered_html_docs_locations(GetMaxRegisteredLocations()) { /* ... */ } + RegisteredLocationResolverImpl() : m_program_redirector(), m_registered_program_locations(GetMaxRegisteredLocations()), m_html_docs_redirector(), m_registered_html_docs_locations(GetMaxRegisteredLocations()) { /* ... */ } ~RegisteredLocationResolverImpl(); public: /* Actual commands. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp index 599982e0f..ede5a1526 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp @@ -28,7 +28,7 @@ namespace ams::ncm { char m_mount_name[fs::MountNameLengthMax + 1]; bool m_disabled; protected: - ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs) : m_kvs(kvs), m_disabled(false) { /* ... */ } + ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs) : m_kvs(kvs), m_mount_name(), m_disabled(false) { /* ... */ } ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs, const char *mount_name) : ContentMetaDatabaseImplBase(kvs) { std::strcpy(m_mount_name, mount_name); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp index bb2e82b67..2fb3cbbb2 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp @@ -26,7 +26,7 @@ namespace ams::ncm { MakeContentPathFunction m_make_content_path_func; bool m_disabled; protected: - ContentStorageImplBase() : m_make_content_path_func(), m_disabled(false) { /* ... */ } + ContentStorageImplBase() : m_root_path(), m_make_content_path_func(), m_disabled(false) { /* ... */ } protected: /* Helpers. */ Result EnsureEnabled() const { diff --git a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp index f0113b86b..96c9b5f59 100644 --- a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp @@ -42,7 +42,7 @@ namespace ams::ncm { CacheEntry *FindInCache(PlaceHolderId placeholder_id); CacheEntry *GetFreeEntry();; public: - PlaceHolderAccessor() : m_cur_counter(0), m_cache_mutex(), m_delay_flush(false) { + PlaceHolderAccessor() : m_root_path(nullptr), m_cur_counter(0), m_cache_mutex(), m_make_placeholder_path_func(nullptr), m_delay_flush(false) { for (size_t i = 0; i < MaxCacheEntries; i++) { m_caches[i].id = InvalidPlaceHolderId; } diff --git a/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp b/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp index cb3bb4624..85b3d2a8e 100644 --- a/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp @@ -55,7 +55,7 @@ namespace ams::ncm { } }; - SubmissionPackageInstallTask::SubmissionPackageInstallTask() { /* ... */ } + SubmissionPackageInstallTask::SubmissionPackageInstallTask() : m_impl(nullptr) { /* ... */ } SubmissionPackageInstallTask::~SubmissionPackageInstallTask() { /* ... */ } Result SubmissionPackageInstallTask::Initialize(fs::FileHandle file, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket) {