diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index 925654cd37..b66ffc856b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -720,12 +720,12 @@ error_code sys_usbd_register_ldd(ppu_thread& ppu, u32 handle, vm::ptr s_pr // The register_ldd appears to be a more promiscuous mode function, where all device 'inserts' would be presented to the cellUsbd for Probing. // Unsure how many more devices might need similar treatment (i.e. just a compare and force VID/PID add), or if it's worth adding a full promiscuous // capability - if (strcmp(s_product.get_ptr(), "guncon3") == 0) + if (s_product.get_ptr() == "guncon3"sv) { sys_usbd.warning("sys_usbd_register_ldd(handle=0x%x, s_product=%s, slen_product=0x%x) -> Redirecting to sys_usbd_register_extra_ldd", handle, s_product, slen_product); sys_usbd_register_extra_ldd(ppu, handle, s_product, slen_product, 0x0B9A, 0x0800, 0x0800); } - else if (strcmp(s_product.get_ptr(), "PS3A-USJ") == 0) + else if (s_product.get_ptr() == "PS3A-USJ"sv) { // Arcade v406 USIO board sys_usbd.warning("sys_usbd_register_ldd(handle=0x%x, s_product=%s, slen_product=0x%x) -> Redirecting to sys_usbd_register_extra_ldd", handle, s_product, slen_product); diff --git a/rpcs3/Emu/RSX/VK/vkutils/instance.hpp b/rpcs3/Emu/RSX/VK/vkutils/instance.hpp index a263498da6..1601da59bb 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/instance.hpp +++ b/rpcs3/Emu/RSX/VK/vkutils/instance.hpp @@ -46,9 +46,9 @@ namespace vk } } - bool is_supported(const char* ext) + bool is_supported(std::string_view ext) { - return std::any_of(m_vk_exts.cbegin(), m_vk_exts.cend(), [&](const VkExtensionProperties& p) { return std::strcmp(p.extensionName, ext) == 0; }); + return std::any_of(m_vk_exts.cbegin(), m_vk_exts.cend(), [&](const VkExtensionProperties& p) { return p.extensionName == ext; }); } }; diff --git a/rpcs3/Loader/TRP.cpp b/rpcs3/Loader/TRP.cpp index c462b9a922..a43e85fdcf 100644 --- a/rpcs3/Loader/TRP.cpp +++ b/rpcs3/Loader/TRP.cpp @@ -11,7 +11,7 @@ TRPLoader::TRPLoader(const fs::file& f) { } -bool TRPLoader::Install(const std::string& dest, bool /*show*/) +bool TRPLoader::Install(std::string_view dest, bool /*show*/) { if (!trp_f) { @@ -151,11 +151,16 @@ u64 TRPLoader::GetRequiredSpace() const return file_size - sizeof(m_header) - file_element_size; } -bool TRPLoader::ContainsEntry(const char *filename) +bool TRPLoader::ContainsEntry(std::string_view filename) { + if (filename.size() >= sizeof(TRPEntry::name)) + { + return false; + } + for (const TRPEntry& entry : m_entries) { - if (!strcmp(entry.name, filename)) + if (entry.name == filename) { return true; } @@ -163,12 +168,17 @@ bool TRPLoader::ContainsEntry(const char *filename) return false; } -void TRPLoader::RemoveEntry(const char *filename) +void TRPLoader::RemoveEntry(std::string_view filename) { + if (filename.size() >= sizeof(TRPEntry::name)) + { + return; + } + std::vector::iterator i = m_entries.begin(); while (i != m_entries.end()) { - if (!strcmp(i->name, filename)) + if (i->name == filename) { i = m_entries.erase(i); } @@ -179,13 +189,18 @@ void TRPLoader::RemoveEntry(const char *filename) } } -void TRPLoader::RenameEntry(const char *oldname, const char *newname) +void TRPLoader::RenameEntry(std::string_view oldname, std::string_view newname) { + if (oldname.size() >= sizeof(TRPEntry::name) || newname.size() >= sizeof(TRPEntry::name)) + { + return; + } + for (TRPEntry& entry : m_entries) { - if (!strcmp(entry.name, oldname)) + if (entry.name == oldname) { - strcpy_trunc(entry.name, std::string_view(newname)); + strcpy_trunc(entry.name, newname); } } } diff --git a/rpcs3/Loader/TRP.h b/rpcs3/Loader/TRP.h index de677836c3..cc096b7a78 100644 --- a/rpcs3/Loader/TRP.h +++ b/rpcs3/Loader/TRP.h @@ -30,11 +30,11 @@ class TRPLoader final public: TRPLoader(const fs::file& f); - bool Install(const std::string& dest, bool show = false); + bool Install(std::string_view dest, bool show = false); bool LoadHeader(bool show = false); u64 GetRequiredSpace() const; - bool ContainsEntry(const char *filename); - void RemoveEntry(const char *filename); - void RenameEntry(const char *oldname, const char *newname); + bool ContainsEntry(std::string_view filename); + void RemoveEntry(std::string_view filename); + void RenameEntry(std::string_view oldname, std::string_view newname); };