From 981166783b539b4a64b88b2bc568fc290d1effc9 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 22 Feb 2020 23:16:53 -0800 Subject: [PATCH] stratosphere: misc static -> global --- stratosphere/creport/source/creport_modules.cpp | 12 +++++++----- stratosphere/loader/source/ldr_ro_manager.cpp | 5 ++--- stratosphere/spl/source/spl_api_impl.cpp | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/stratosphere/creport/source/creport_modules.cpp b/stratosphere/creport/source/creport_modules.cpp index 06618b063..ca7093afa 100644 --- a/stratosphere/creport/source/creport_modules.cpp +++ b/stratosphere/creport/source/creport_modules.cpp @@ -39,6 +39,9 @@ namespace ams::creport { }; static_assert(sizeof(RoDataStart) == sizeof(ModulePath), "RoDataStart definition!"); + /* Globals. */ + u8 g_last_rodata_pages[2 * os::MemoryPageSize]; + } void ModuleList::SaveToFile(FILE *f_report) { @@ -229,16 +232,15 @@ namespace ams::creport { } /* We want to read the last two pages of .rodata. */ - static u8 s_last_rodata_pages[2 * os::MemoryPageSize]; - const size_t read_size = mi.size >= sizeof(s_last_rodata_pages) ? sizeof(s_last_rodata_pages) : (sizeof(s_last_rodata_pages) / 2); - if (R_FAILED(svcReadDebugProcessMemory(s_last_rodata_pages, this->debug_handle, mi.addr + mi.size - read_size, read_size))) { + const size_t read_size = mi.size >= sizeof(g_last_rodata_pages) ? sizeof(g_last_rodata_pages) : (sizeof(g_last_rodata_pages) / 2); + if (R_FAILED(svcReadDebugProcessMemory(g_last_rodata_pages, this->debug_handle, mi.addr + mi.size - read_size, read_size))) { return; } /* Find GNU\x00 to locate start of build id. */ for (int ofs = read_size - sizeof(GnuSignature) - ModuleBuildIdLength; ofs >= 0; ofs--) { - if (std::memcmp(s_last_rodata_pages + ofs, GnuSignature, sizeof(GnuSignature)) == 0) { - std::memcpy(out_build_id, s_last_rodata_pages + ofs + sizeof(GnuSignature), ModuleBuildIdLength); + if (std::memcmp(g_last_rodata_pages + ofs, GnuSignature, sizeof(GnuSignature)) == 0) { + std::memcpy(out_build_id, g_last_rodata_pages + ofs + sizeof(GnuSignature), ModuleBuildIdLength); break; } } diff --git a/stratosphere/loader/source/ldr_ro_manager.cpp b/stratosphere/loader/source/ldr_ro_manager.cpp index ea64ad01f..901d22137 100644 --- a/stratosphere/loader/source/ldr_ro_manager.cpp +++ b/stratosphere/loader/source/ldr_ro_manager.cpp @@ -42,6 +42,7 @@ namespace ams::ldr::ro { /* Globals. */ ProcessInfo g_process_infos[ProcessCountMax]; + u64 g_cur_pin_id = 1; /* Helpers. */ ProcessInfo *GetProcessInfo(PinId pin_id) { @@ -82,10 +83,8 @@ namespace ams::ldr::ro { ProcessInfo *info = GetFreeProcessInfo(); R_UNLESS(info != nullptr, ldr::ResultTooManyProcesses()); - static u64 s_cur_pin_id = 1; - std::memset(info, 0, sizeof(*info)); - info->pin_id = { s_cur_pin_id++ }; + info->pin_id = { g_cur_pin_id++ }; info->loc = loc; info->override_status = status; info->in_use = true; diff --git a/stratosphere/spl/source/spl_api_impl.cpp b/stratosphere/spl/source/spl_api_impl.cpp index 8b7765705..2416b3dee 100644 --- a/stratosphere/spl/source/spl_api_impl.cpp +++ b/stratosphere/spl/source/spl_api_impl.cpp @@ -555,7 +555,7 @@ namespace ams::spl::impl { Result GenerateAesKey(AesKey *out_key, const AccessKey &access_key, const KeySource &key_source) { smc::Result smc_rc; - static const KeySource s_generate_aes_key_source = { + static constexpr KeySource s_generate_aes_key_source = { .data = {0x89, 0x61, 0x5E, 0xE0, 0x5C, 0x31, 0xB6, 0x80, 0x5F, 0xE5, 0x8F, 0x3D, 0xA2, 0x4F, 0x7A, 0xA8} }; @@ -571,7 +571,7 @@ namespace ams::spl::impl { } Result DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option) { - static const KeySource s_decrypt_aes_key_source = { + static constexpr KeySource s_decrypt_aes_key_source = { .data = {0x11, 0x70, 0x24, 0x2B, 0x48, 0x69, 0x11, 0xF1, 0x11, 0xB0, 0x0C, 0x47, 0x7C, 0xC3, 0xEF, 0x7E} };