SmallString: Make constructors explicit

Catch more errors at compile-time.
pull/3553/head
Stenzek 2 months ago
parent d9dc5074df
commit 78fa54344e
No known key found for this signature in database

@ -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);

@ -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);

@ -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.

@ -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
}

@ -249,7 +249,7 @@ std::optional<VkSurfaceFormatKHR> 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<unsigned>(sf.format));
Error::SetStringView(error, errormsg);

Loading…
Cancel
Save