diff --git a/src/common/small_string.h b/src/common/small_string.h index c059f3c7e..5e5dbdaed 100644 --- a/src/common/small_string.h +++ b/src/common/small_string.h @@ -266,13 +266,13 @@ class SmallStackString : public SmallStringBase public: ALWAYS_INLINE SmallStackString() { init(); } - ALWAYS_INLINE SmallStackString(const char* str) + ALWAYS_INLINE explicit SmallStackString(const char* str) { init(); assign(str); } - ALWAYS_INLINE SmallStackString(const char* str, u32 length) + ALWAYS_INLINE explicit SmallStackString(const char* str, u32 length) { init(); assign(str, length); @@ -290,19 +290,25 @@ public: assign(move); } - ALWAYS_INLINE SmallStackString(const SmallStackString& copy) + ALWAYS_INLINE explicit SmallStackString(const SmallStackString& copy) { init(); assign(copy); } - ALWAYS_INLINE SmallStackString(SmallStackString&& move) + ALWAYS_INLINE explicit SmallStackString(SmallStackString&& move) { init(); assign(move); } - ALWAYS_INLINE SmallStackString(const std::string_view sv) + ALWAYS_INLINE explicit SmallStackString(const std::string& str) + { + init(); + assign(str); + } + + ALWAYS_INLINE explicit SmallStackString(const std::string_view sv) { init(); assign(sv); @@ -332,6 +338,12 @@ public: return *this; } + ALWAYS_INLINE SmallStackString& operator=(const std::string& str) + { + assign(str); + return *this; + } + ALWAYS_INLINE SmallStackString& operator=(const std::string_view sv) { assign(sv); diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index d939cc8f7..079cec748 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -3815,7 +3815,7 @@ static TinyString GetLoginEncryptionMachineKey() { WARNING_LOG("Get MachineGuid failed: {}", error); RegCloseKey(hKey); - return 0; + return ret; } ret.resize(machine_guid_length); @@ -3826,7 +3826,7 @@ static TinyString GetLoginEncryptionMachineKey() WARNING_LOG("Read MachineGuid failed: {}", error); ret = {}; RegCloseKey(hKey); - return 0; + return ret; } ret.resize(machine_guid_length); diff --git a/src/core/system.cpp b/src/core/system.cpp index 471dac826..f53d4c0c6 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -6192,7 +6192,7 @@ void System::UpdateRichPresence(bool update_session_time) rp.largeImageText = "DuckStation PS1/PSX Emulator"; rp.startTimestamp = s_state.discord_presence_time_epoch; - TinyString game_details = "No Game Running"; + TinyString game_details("No Game Running"); if (IsValidOrInitializing()) { // Use disc set name if it's not a custom title. diff --git a/src/util/cubeb_audio_stream.cpp b/src/util/cubeb_audio_stream.cpp index e01cbfe78..52c7299c9 100644 --- a/src/util/cubeb_audio_stream.cpp +++ b/src/util/cubeb_audio_stream.cpp @@ -59,7 +59,8 @@ static TinyString GetCubebErrorString(int rv) C(CUBEB_ERROR_DEVICE_UNAVAILABLE); default: - return "CUBEB_ERROR_UNKNOWN"; + ret = "CUBEB_ERROR_UNKNOWN"; + break; #undef C } diff --git a/src/util/vulkan_swap_chain.cpp b/src/util/vulkan_swap_chain.cpp index 0973acc19..c9556a559 100644 --- a/src/util/vulkan_swap_chain.cpp +++ b/src/util/vulkan_swap_chain.cpp @@ -249,7 +249,7 @@ std::optional VulkanSwapChain::SelectSurfaceFormat(VkPhysica return VkSurfaceFormatKHR{format, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR}; } - SmallString errormsg = "Failed to find a suitable format for swap chain buffers. Available formats were:"; + SmallString errormsg("Failed to find a suitable format for swap chain buffers. Available formats were:"); for (const VkSurfaceFormatKHR& sf : surface_formats) errormsg.append_format(" {}", static_cast(sf.format)); Error::SetStringView(error, errormsg);