Misc: Fix a bunch of code analysis warnings

Some of which were even actual errors.
This commit is contained in:
Stenzek 2024-08-02 23:56:06 +10:00
parent 4eb3b2a9a7
commit 3a83c4265c
No known key found for this signature in database
30 changed files with 93 additions and 78 deletions

View file

@ -90,7 +90,7 @@ public:
ALWAYS_INLINE BinarySpanReader& operator>>(s64& val) { val = ReadT<s64>(); return *this; } ALWAYS_INLINE BinarySpanReader& operator>>(s64& val) { val = ReadT<s64>(); return *this; }
ALWAYS_INLINE BinarySpanReader& operator>>(u64& val) { val = ReadT<u64>(); return *this; } ALWAYS_INLINE BinarySpanReader& operator>>(u64& val) { val = ReadT<u64>(); return *this; }
ALWAYS_INLINE BinarySpanReader& operator>>(float& val) { val = ReadT<float>(); return *this; } ALWAYS_INLINE BinarySpanReader& operator>>(float& val) { val = ReadT<float>(); return *this; }
ALWAYS_INLINE BinarySpanReader& operator>>(std::string_view val) { val = ReadCString(); return *this; } ALWAYS_INLINE BinarySpanReader& operator>>(std::string_view& val) { val = ReadCString(); return *this; }
// clang-format on // clang-format on
template<typename T> template<typename T>
@ -272,7 +272,7 @@ public:
ALWAYS_INLINE BinaryFileReader& operator>>(s64& val) { val = ReadT<s64>(); return *this; } ALWAYS_INLINE BinaryFileReader& operator>>(s64& val) { val = ReadT<s64>(); return *this; }
ALWAYS_INLINE BinaryFileReader& operator>>(u64& val) { val = ReadT<u64>(); return *this; } ALWAYS_INLINE BinaryFileReader& operator>>(u64& val) { val = ReadT<u64>(); return *this; }
ALWAYS_INLINE BinaryFileReader& operator>>(float& val) { val = ReadT<float>(); return *this; } ALWAYS_INLINE BinaryFileReader& operator>>(float& val) { val = ReadT<float>(); return *this; }
ALWAYS_INLINE BinaryFileReader& operator>>(std::string_view val) { val = ReadCString(); return *this; } ALWAYS_INLINE BinaryFileReader& operator>>(std::string_view& val) { val = ReadCString(); return *this; }
// clang-format on // clang-format on
template<typename T> template<typename T>

View file

@ -505,7 +505,7 @@ std::string Path::Canonicalize(std::string_view path)
{ {
// current directory, so it can be skipped, unless it's the only component // current directory, so it can be skipped, unless it's the only component
if (components.size() == 1) if (components.size() == 1)
new_components.push_back(std::move(component)); new_components.push_back(component);
} }
else if (component == "..") else if (component == "..")
{ {
@ -513,12 +513,12 @@ std::string Path::Canonicalize(std::string_view path)
if (!new_components.empty()) if (!new_components.empty())
new_components.pop_back(); new_components.pop_back();
else else
new_components.push_back(std::move(component)); new_components.push_back(component);
} }
else else
{ {
// anything else, preserve // anything else, preserve
new_components.push_back(std::move(component)); new_components.push_back(component);
} }
} }

View file

@ -233,11 +233,11 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageAndPrintW(const char* channelNam
wmessage_buflen = wmessage_buflen =
MultiByteToWideChar(CP_UTF8, 0, buffer.data(), static_cast<int>(buffer.size()), wmessage_buf, wmessage_buflen); MultiByteToWideChar(CP_UTF8, 0, buffer.data(), static_cast<int>(buffer.size()), wmessage_buf, wmessage_buflen);
if (wmessage_buflen <= 0) if (wmessage_buflen > 0) [[likely]]
return; {
wmessage_buf[wmessage_buflen] = '\0'; wmessage_buf[wmessage_buflen] = '\0';
callback(std::wstring_view(wmessage_buf, wmessage_buflen)); callback(std::wstring_view(wmessage_buf, wmessage_buflen));
}
if (wmessage_buf != wbuf) if (wmessage_buf != wbuf)
std::free(wmessage_buf); std::free(wmessage_buf);

View file

@ -67,12 +67,12 @@ std::string MemMap::GetFileMappingName(const char* prefix)
void* MemMap::CreateSharedMemory(const char* name, size_t size, Error* error) void* MemMap::CreateSharedMemory(const char* name, size_t size, Error* error)
{ {
const HANDLE mapping = const HANDLE mapping =
static_cast<void*>(CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, static_cast<DWORD>(size >> 32), CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, static_cast<DWORD>(size >> 32),
static_cast<DWORD>(size), StringUtil::UTF8StringToWideString(name).c_str())); static_cast<DWORD>(size), StringUtil::UTF8StringToWideString(name).c_str());
if (!mapping) if (!mapping)
Error::SetWin32(error, "CreateFileMappingW() failed: ", GetLastError()); Error::SetWin32(error, "CreateFileMappingW() failed: ", GetLastError());
return mapping; return static_cast<void*>(mapping);
} }
void MemMap::DestroySharedMemory(void* ptr) void MemMap::DestroySharedMemory(void* ptr)

View file

@ -248,10 +248,12 @@ void SmallStringBase::append_vsprintf(const char* format, va_list ap)
va_copy(ap_copy, ap); va_copy(ap_copy, ap);
const int ret = std::vsnprintf(buffer, buffer_size, format, ap_copy); const int ret = std::vsnprintf(buffer, buffer_size, format, ap_copy);
va_end(ap_copy); va_end(ap_copy);
if (ret < 0 || ((u32)ret >= (buffer_size - 1))) if (ret < 0 || (static_cast<u32>(ret) >= (buffer_size - 1)))
{ {
buffer_size *= 2; buffer_size *= 2;
buffer = heap_buffer = reinterpret_cast<char*>(std::realloc(heap_buffer, buffer_size)); buffer = heap_buffer = reinterpret_cast<char*>(std::realloc(heap_buffer, buffer_size));
if (!buffer) [[unlikely]]
Panic("Memory allocation failed.");
continue; continue;
} }
@ -303,7 +305,7 @@ void SmallStringBase::prepend_vsprintf(const char* format, va_list ArgPtr)
// We have a 1KB byte buffer on the stack here. If this is too little, we'll grow it via the heap, // We have a 1KB byte buffer on the stack here. If this is too little, we'll grow it via the heap,
// but 1KB should be enough for most strings. // but 1KB should be enough for most strings.
char stack_buffer[1024]; char stack_buffer[1024];
char* heap_buffer = NULL; char* heap_buffer = nullptr;
char* buffer = stack_buffer; char* buffer = stack_buffer;
u32 buffer_size = static_cast<u32>(std::size(stack_buffer)); u32 buffer_size = static_cast<u32>(std::size(stack_buffer));
u32 written; u32 written;
@ -315,6 +317,8 @@ void SmallStringBase::prepend_vsprintf(const char* format, va_list ArgPtr)
{ {
buffer_size *= 2; buffer_size *= 2;
buffer = heap_buffer = reinterpret_cast<char*>(std::realloc(heap_buffer, buffer_size)); buffer = heap_buffer = reinterpret_cast<char*>(std::realloc(heap_buffer, buffer_size));
if (!buffer) [[unlikely]]
Panic("Memory allocation failed.");
continue; continue;
} }

View file

@ -351,7 +351,7 @@ std::optional<BIOS::Image> BIOS::FindBIOSImageInDirectory(ConsoleRegion region,
std::string full_path(Path::Combine(directory, fd.FileName)); std::string full_path(Path::Combine(directory, fd.FileName));
std::optional<Image> found_image = LoadImageFromFile(full_path.c_str(), nullptr); std::optional<Image> found_image = LoadImageFromFile(full_path.c_str(), nullptr);
if (!found_image) if (!found_image.has_value())
continue; continue;
if (found_image->info && IsValidBIOSForRegion(region, found_image->info->region)) if (found_image->info && IsValidBIOSForRegion(region, found_image->info->region))

View file

@ -1399,8 +1399,11 @@ template<MemoryAccessSize size>
u32 Bus::HWHandlers::MemCtrlRead(PhysicalMemoryAddress address) u32 Bus::HWHandlers::MemCtrlRead(PhysicalMemoryAddress address)
{ {
const u32 offset = address & MEMCTRL_MASK; const u32 offset = address & MEMCTRL_MASK;
const u32 index = FIXUP_WORD_OFFSET(size, offset) / 4;
if (index >= std::size(s_MEMCTRL.regs)) [[unlikely]]
return 0;
u32 value = s_MEMCTRL.regs[FIXUP_WORD_OFFSET(size, offset) / 4]; u32 value = s_MEMCTRL.regs[index];
value = FIXUP_WORD_READ_VALUE(size, offset, value); value = FIXUP_WORD_READ_VALUE(size, offset, value);
BUS_CYCLES(2); BUS_CYCLES(2);
return value; return value;
@ -1411,6 +1414,9 @@ void Bus::HWHandlers::MemCtrlWrite(PhysicalMemoryAddress address, u32 value)
{ {
const u32 offset = address & MEMCTRL_MASK; const u32 offset = address & MEMCTRL_MASK;
const u32 index = FIXUP_WORD_OFFSET(size, offset) / 4; const u32 index = FIXUP_WORD_OFFSET(size, offset) / 4;
if (index >= std::size(s_MEMCTRL.regs)) [[unlikely]]
return;
value = FIXUP_WORD_WRITE_VALUE(size, offset, value); value = FIXUP_WORD_WRITE_VALUE(size, offset, value);
const u32 write_mask = (index == 8) ? COMDELAY::WRITE_MASK : MEMDELAY::WRITE_MASK; const u32 write_mask = (index == 8) ? COMDELAY::WRITE_MASK : MEMDELAY::WRITE_MASK;
@ -1516,6 +1522,7 @@ u32 Bus::HWHandlers::CDROMRead(PhysicalMemoryAddress address)
const u32 b3 = ZeroExtend32(CDROM::ReadRegister(offset + 3u)); const u32 b3 = ZeroExtend32(CDROM::ReadRegister(offset + 3u));
value = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); value = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
} }
break;
case MemoryAccessSize::HalfWord: case MemoryAccessSize::HalfWord:
{ {
@ -1523,10 +1530,12 @@ u32 Bus::HWHandlers::CDROMRead(PhysicalMemoryAddress address)
const u32 msb = ZeroExtend32(CDROM::ReadRegister(offset + 1u)); const u32 msb = ZeroExtend32(CDROM::ReadRegister(offset + 1u));
value = lsb | (msb << 8); value = lsb | (msb << 8);
} }
break;
case MemoryAccessSize::Byte: case MemoryAccessSize::Byte:
default: default:
value = ZeroExtend32(CDROM::ReadRegister(offset)); value = ZeroExtend32(CDROM::ReadRegister(offset));
break;
} }
BUS_CYCLES(Bus::g_cdrom_access_time[static_cast<u32>(size)]); BUS_CYCLES(Bus::g_cdrom_access_time[static_cast<u32>(size)]);

View file

@ -661,8 +661,10 @@ bool CheatList::LoadFromString(const std::string& str, Format format)
return LoadFromPCSXRString(str); return LoadFromPCSXRString(str);
else if (format == Format::Libretro) else if (format == Format::Libretro)
return LoadFromLibretroString(str); return LoadFromLibretroString(str);
format = Format::EPSXe; else if (format == Format::EPSXe)
return LoadFromEPSXeString(str); return LoadFromEPSXeString(str);
else
return false;
} }
bool CheatList::SaveToPCSXRFile(const char* filename) bool CheatList::SaveToPCSXRFile(const char* filename)
@ -2782,7 +2784,7 @@ const char* CheatCode::GetTypeDisplayName(Type type)
std::optional<CheatCode::Type> CheatCode::ParseTypeName(const char* str) std::optional<CheatCode::Type> CheatCode::ParseTypeName(const char* str)
{ {
for (u32 i = 0; i < static_cast<u32>(s_cheat_code_type_names.size()); i++) for (size_t i = 0; i < s_cheat_code_type_names.size(); i++)
{ {
if (std::strcmp(s_cheat_code_type_names[i], str) == 0) if (std::strcmp(s_cheat_code_type_names[i], str) == 0)
return static_cast<Type>(i); return static_cast<Type>(i);

View file

@ -1172,7 +1172,7 @@ void FullscreenUI::DoChangeDisc()
if (const GameDatabase::Entry* entry = System::GetGameDatabaseEntry(); entry && !entry->disc_set_serials.empty()) if (const GameDatabase::Entry* entry = System::GetGameDatabaseEntry(); entry && !entry->disc_set_serials.empty())
{ {
const auto lock = GameList::GetLock(); const auto lock = GameList::GetLock();
const auto matches = GameList::GetMatchingEntriesForSerial(entry->disc_set_serials); auto matches = GameList::GetMatchingEntriesForSerial(entry->disc_set_serials);
if (matches.size() > 1) if (matches.size() > 1)
{ {
options.reserve(matches.size() + 1); options.reserve(matches.size() + 1);
@ -5759,7 +5759,7 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
if (i == 0) if (i == 0)
ResetFocusHere(); ResetFocusHere();
const SaveStateListEntry& entry = s_save_state_selector_slots[i]; SaveStateListEntry& entry = s_save_state_selector_slots[i];
if (static_cast<s32>(i) == s_save_state_selector_submenu_index) if (static_cast<s32>(i) == s_save_state_selector_submenu_index)
{ {
// can't use a choice dialog here, because we're already in a modal... // can't use a choice dialog here, because we're already in a modal...
@ -6021,7 +6021,7 @@ void FullscreenUI::DrawResumeStateSelector()
if (ImGui::BeginPopupModal(FSUI_CSTR("Load Resume State"), &is_open, if (ImGui::BeginPopupModal(FSUI_CSTR("Load Resume State"), &is_open,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize))
{ {
const SaveStateListEntry& entry = s_save_state_selector_slots.front(); SaveStateListEntry& entry = s_save_state_selector_slots.front();
SmallString time; SmallString time;
TimeToPrintableString(&time, entry.timestamp); TimeToPrintableString(&time, entry.timestamp);
ImGui::TextWrapped( ImGui::TextWrapped(

View file

@ -1736,10 +1736,10 @@ std::string GameList::GetGameIconPath(std::string_view serial, std::string_view
// Try extracting an icon. // Try extracting an icon.
Error error; Error error;
MemoryCardImage::DataArray data; std::unique_ptr<MemoryCardImage::DataArray> data = std::make_unique<MemoryCardImage::DataArray>();
if (MemoryCardImage::LoadFromFile(&data, memcard_path.c_str(), &error)) if (MemoryCardImage::LoadFromFile(data.get(), memcard_path.c_str(), &error))
{ {
std::vector<MemoryCardImage::FileInfo> files = MemoryCardImage::EnumerateFiles(data, false); std::vector<MemoryCardImage::FileInfo> files = MemoryCardImage::EnumerateFiles(*data.get(), false);
if (!files.empty()) if (!files.empty())
{ {
const MemoryCardImage::FileInfo& fi = files.front(); const MemoryCardImage::FileInfo& fi = files.front();

View file

@ -2253,7 +2253,6 @@ void GPU_HW::DrawLine(const GSVector4 bounds, u32 col0, u32 col1, float depth)
const float abs_dx = std::fabs(dx); const float abs_dx = std::fabs(dx);
const float abs_dy = std::fabs(dy); const float abs_dy = std::fabs(dy);
float fill_dx, fill_dy; float fill_dx, fill_dy;
float dxdk, dydk;
float pad_x0 = 0.0f; float pad_x0 = 0.0f;
float pad_x1 = 0.0f; float pad_x1 = 0.0f;
float pad_y0 = 0.0f; float pad_y0 = 0.0f;
@ -2268,8 +2267,7 @@ void GPU_HW::DrawLine(const GSVector4 bounds, u32 col0, u32 col1, float depth)
{ {
fill_dx = 0.0f; fill_dx = 0.0f;
fill_dy = 1.0f; fill_dy = 1.0f;
dxdk = 1.0f; const float dydk = dy / abs_dx;
dydk = dy / abs_dx;
if (dx > 0.0f) if (dx > 0.0f)
{ {
@ -2288,8 +2286,7 @@ void GPU_HW::DrawLine(const GSVector4 bounds, u32 col0, u32 col1, float depth)
{ {
fill_dx = 1.0f; fill_dx = 1.0f;
fill_dy = 0.0f; fill_dy = 0.0f;
dydk = 1.0f; const float dxdk = dx / abs_dy;
dxdk = dx / abs_dy;
if (dy > 0.0f) if (dy > 0.0f)
{ {

View file

@ -239,7 +239,6 @@ void ImGuiManager::DrawPerformanceOverlay()
ImDrawList* dl = ImGui::GetBackgroundDrawList(); ImDrawList* dl = ImGui::GetBackgroundDrawList();
SmallString text; SmallString text;
ImVec2 text_size; ImVec2 text_size;
bool first = true;
#define DRAW_LINE(font, text, color) \ #define DRAW_LINE(font, text, color) \
do \ do \
@ -260,21 +259,16 @@ void ImGuiManager::DrawPerformanceOverlay()
{ {
const float speed = System::GetEmulationSpeed(); const float speed = System::GetEmulationSpeed();
if (g_settings.display_show_fps) if (g_settings.display_show_fps)
{
text.append_format("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS()); text.append_format("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS());
first = false;
}
if (g_settings.display_show_speed) if (g_settings.display_show_speed)
{ {
text.append_format("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed))); text.append_format("{}{}%", text.empty() ? "" : " | ", static_cast<u32>(std::round(speed)));
const float target_speed = System::GetTargetSpeed(); const float target_speed = System::GetTargetSpeed();
if (target_speed <= 0.0f) if (target_speed <= 0.0f)
text.append(" (Max)"); text.append(" (Max)");
else else
text.append_format(" ({:.0f}%)", target_speed * 100.0f); text.append_format(" ({:.0f}%)", target_speed * 100.0f);
first = false;
} }
if (!text.empty()) if (!text.empty())
{ {
@ -325,7 +319,7 @@ void ImGuiManager::DrawPerformanceOverlay()
g_settings.cpu_execution_mode != CPUExecutionMode::Recompiler || g_settings.cpu_recompiler_icache || g_settings.cpu_execution_mode != CPUExecutionMode::Recompiler || g_settings.cpu_recompiler_icache ||
g_settings.cpu_recompiler_memory_exceptions) g_settings.cpu_recompiler_memory_exceptions)
{ {
first = true; bool first = true;
text.assign("CPU["); text.assign("CPU[");
if (g_settings.cpu_overclock_active) if (g_settings.cpu_overclock_active)
{ {

View file

@ -962,11 +962,11 @@ bool System::ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_n
bool System::ReadExecutableFromImage(IsoReader& iso, std::string* out_executable_name, bool System::ReadExecutableFromImage(IsoReader& iso, std::string* out_executable_name,
std::vector<u8>* out_executable_data) std::vector<u8>* out_executable_data)
{ {
const std::string executable_path = GetExecutableNameForImage(iso, false); std::string executable_path = GetExecutableNameForImage(iso, false);
DEV_LOG("Executable path: '{}'", executable_path); DEV_LOG("Executable path: '{}'", executable_path);
if (!executable_path.empty() && out_executable_data) if (!executable_path.empty() && out_executable_data)
{ {
if (!iso.ReadFile(executable_path.c_str(), out_executable_data)) if (!iso.ReadFile(executable_path, out_executable_data))
{ {
ERROR_LOG("Failed to read executable '{}' from disc", executable_path); ERROR_LOG("Failed to read executable '{}' from disc", executable_path);
return false; return false;
@ -993,25 +993,30 @@ System::GameHash System::GetGameHashFromBuffer(std::string_view exe_name, std::s
return hash; return hash;
} }
DiscRegion System::GetRegionForSerial(std::string_view serial) DiscRegion System::GetRegionForSerial(const std::string_view serial)
{ {
std::string prefix; static constexpr const std::pair<const char*, DiscRegion> region_prefixes[] = {
for (size_t pos = 0; pos < serial.length(); pos++) {"sces", DiscRegion::PAL},
{ {"sced", DiscRegion::PAL},
const int ch = std::tolower(serial[pos]); {"sles", DiscRegion::PAL},
if (ch < 'a' || ch > 'z') {"sled", DiscRegion::PAL},
break;
prefix.push_back(static_cast<char>(ch)); {"scps", DiscRegion::NTSC_J},
{"slps", DiscRegion::NTSC_J},
{"slpm", DiscRegion::NTSC_J},
{"sczs", DiscRegion::NTSC_J},
{"papx", DiscRegion::NTSC_J},
{"scus", DiscRegion::NTSC_U},
{"slus", DiscRegion::NTSC_U},
};
for (const auto& [prefix, region] : region_prefixes)
{
if (StringUtil::StartsWithNoCase(serial, prefix))
return region;
} }
if (prefix == "sces" || prefix == "sced" || prefix == "sles" || prefix == "sled")
return DiscRegion::PAL;
else if (prefix == "scps" || prefix == "slps" || prefix == "slpm" || prefix == "sczs" || prefix == "papx")
return DiscRegion::NTSC_J;
else if (prefix == "scus" || prefix == "slus")
return DiscRegion::NTSC_U;
else
return DiscRegion::Other; return DiscRegion::Other;
} }
@ -1311,7 +1316,7 @@ bool System::UpdateGameSettingsLayer()
std::unique_ptr<INISettingsInterface> input_interface; std::unique_ptr<INISettingsInterface> input_interface;
if (!input_profile_name.empty()) if (!input_profile_name.empty())
{ {
const std::string filename(GetInputProfilePath(input_profile_name)); std::string filename = GetInputProfilePath(input_profile_name);
if (FileSystem::FileExists(filename.c_str())) if (FileSystem::FileExists(filename.c_str()))
{ {
INFO_LOG("Loading input profile from '{}'...", Path::GetFileName(filename)); INFO_LOG("Loading input profile from '{}'...", Path::GetFileName(filename));

View file

@ -142,7 +142,7 @@ bool ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_name, std
std::string GetGameHashId(GameHash hash); std::string GetGameHashId(GameHash hash);
bool GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash* out_hash); bool GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash* out_hash);
GameHash GetGameHashFromFile(const char* path); GameHash GetGameHashFromFile(const char* path);
DiscRegion GetRegionForSerial(std::string_view serial); DiscRegion GetRegionForSerial(const std::string_view serial);
DiscRegion GetRegionFromSystemArea(CDImage* cdi); DiscRegion GetRegionFromSystemArea(CDImage* cdi);
DiscRegion GetRegionForImage(CDImage* cdi); DiscRegion GetRegionForImage(CDImage* cdi);
DiscRegion GetRegionForExe(const char* path); DiscRegion GetRegionForExe(const char* path);

View file

@ -215,6 +215,8 @@ void TextureReplacements::Reload()
void TextureReplacements::PurgeUnreferencedTexturesFromCache() void TextureReplacements::PurgeUnreferencedTexturesFromCache()
{ {
TextureCache old_map = std::move(s_texture_cache); TextureCache old_map = std::move(s_texture_cache);
s_texture_cache = {};
for (const auto& it : s_vram_write_replacements) for (const auto& it : s_vram_write_replacements)
{ {
auto it2 = old_map.find(it.second); auto it2 = old_map.find(it.second);

View file

@ -55,6 +55,7 @@ AudioStream::AudioStream(u32 sample_rate, const AudioStreamParameters& parameter
AudioStream::~AudioStream() AudioStream::~AudioStream()
{ {
StretchDestroy();
DestroyBuffer(); DestroyBuffer();
} }

View file

@ -86,7 +86,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
if (!track) if (!track)
break; break;
const std::string track_filename(track->file); const std::string& track_filename = track->file;
LBA track_start = track->start.ToLBA(); LBA track_start = track->start.ToLBA();
u32 track_file_index = 0; u32 track_file_index = 0;
@ -124,7 +124,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
return false; return false;
} }
m_files.push_back(TrackFile{std::move(track_filename), track_fp, 0}); m_files.push_back(TrackFile{track_filename, track_fp, 0});
} }
// data type determines the sector size // data type determines the sector size

View file

@ -83,7 +83,7 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd); const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd);
CDImage::SubChannelQ subq; CDImage::SubChannelQ subq;
std::copy_n(entry.data, countof(entry.data), subq.data.data()); std::memcpy(subq.data.data(), entry.data, sizeof(entry.data));
// generate an invalid crc by flipping all bits from the valid crc (will never collide) // generate an invalid crc by flipping all bits from the valid crc (will never collide)
const u16 crc = subq.ComputeCRC(subq.data) ^ 0xFFFF; const u16 crc = subq.ComputeCRC(subq.data) ^ 0xFFFF;
@ -119,7 +119,7 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path)
const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd); const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd);
CDImage::SubChannelQ subq; CDImage::SubChannelQ subq;
std::copy_n(entry.data, countof(entry.data), subq.data.data()); std::memcpy(subq.data.data(), entry.data, sizeof(entry.data));
DEBUG_LOG("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd, DEBUG_LOG("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
subq.IsCRCValid() ? "VALID" : "INVALID"); subq.IsCRCValid() ? "VALID" : "INVALID");

View file

@ -365,7 +365,7 @@ bool CueParser::File::HandlePregapCommand(const char* line, u32 line_number, Err
return false; return false;
} }
m_current_track->zero_pregap = std::move(msf); m_current_track->zero_pregap = msf;
return true; return true;
} }

View file

@ -11,11 +11,11 @@
Log_SetChannel(D3D11Device); Log_SetChannel(D3D11Device);
D3D11StreamBuffer::D3D11StreamBuffer() : m_size(0), m_position(0) D3D11StreamBuffer::D3D11StreamBuffer()
{ {
} }
D3D11StreamBuffer::D3D11StreamBuffer(ComPtr<ID3D11Buffer> buffer) : m_buffer(std::move(buffer)), m_position(0) D3D11StreamBuffer::D3D11StreamBuffer(ComPtr<ID3D11Buffer> buffer) : m_buffer(std::move(buffer))
{ {
D3D11_BUFFER_DESC desc; D3D11_BUFFER_DESC desc;
m_buffer->GetDesc(&desc); m_buffer->GetDesc(&desc);

View file

@ -42,9 +42,9 @@ public:
private: private:
ComPtr<ID3D11Buffer> m_buffer; ComPtr<ID3D11Buffer> m_buffer;
u32 m_size; u32 m_size = 0;
u32 m_max_size; u32 m_max_size = 0;
u32 m_position; u32 m_position = 0;
bool m_use_map_no_overwrite = false; bool m_use_map_no_overwrite = false;
bool m_mapped = false; bool m_mapped = false;
}; };

View file

@ -753,7 +753,7 @@ std::unique_ptr<GPUSampler> D3D12Device::CreateSampler(const GPUSampler::Config&
if (!handle) if (!handle)
return {}; return {};
return std::unique_ptr<GPUSampler>(new D3D12Sampler(std::move(handle))); return std::unique_ptr<GPUSampler>(new D3D12Sampler(handle));
} }
D3D12TextureBuffer::D3D12TextureBuffer(Format format, u32 size_in_elements) : GPUTextureBuffer(format, size_in_elements) D3D12TextureBuffer::D3D12TextureBuffer(Format format, u32 size_in_elements) : GPUTextureBuffer(format, size_in_elements)

View file

@ -415,7 +415,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
if (m_features.pipeline_cache && !base_path.empty()) if (m_features.pipeline_cache && !base_path.empty())
{ {
const std::string basename = GetShaderCacheBaseName("pipelines"); const std::string basename = GetShaderCacheBaseName("pipelines");
const std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename)); std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename));
if (ReadPipelineCache(filename)) if (ReadPipelineCache(filename))
s_pipeline_cache_path = std::move(filename); s_pipeline_cache_path = std::move(filename);
else else

View file

@ -449,7 +449,7 @@ public:
protected: protected:
Format m_format; Format m_format;
u32 m_size_in_elements; u32 m_size_in_elements;
u32 m_current_position; u32 m_current_position = 0;
}; };
class GPUDevice class GPUDevice

View file

@ -136,7 +136,7 @@ template<typename FBOType, FBOType (*FactoryFunc)(GPUTexture* const* rts, u32 nu
void (*DestroyFunc)(FBOType fbo)> void (*DestroyFunc)(FBOType fbo)>
void GPUFramebufferManager<FBOType, FactoryFunc, DestroyFunc>::Clear() void GPUFramebufferManager<FBOType, FactoryFunc, DestroyFunc>::Clear()
{ {
for (auto it : m_map) for (const auto& it : m_map)
DestroyFunc(it.second); DestroyFunc(it.second);
m_map.clear(); m_map.clear();
} }

View file

@ -76,7 +76,7 @@ private:
CacheIndex m_index; CacheIndex m_index;
std::string m_base_filename; std::string m_base_filename;
u32 m_version; u32 m_version = 0;
std::FILE* m_index_file = nullptr; std::FILE* m_index_file = nullptr;
std::FILE* m_blob_file = nullptr; std::FILE* m_blob_file = nullptr;

View file

@ -75,7 +75,7 @@ std::optional<InputBindingKey> InputSource::ParseGenericControllerKey(InputSourc
return std::nullopt; return std::nullopt;
const std::optional<s32> source_index = StringUtil::FromChars<s32>(source.substr(pos)); const std::optional<s32> source_index = StringUtil::FromChars<s32>(source.substr(pos));
if (source_index.has_value() || source_index.value() < 0) if (!source_index.has_value() || source_index.value() < 0)
return std::nullopt; return std::nullopt;
InputBindingKey key = {}; InputBindingKey key = {};

View file

@ -554,6 +554,7 @@ void OpenGLDevice::CommitRTClearInFB(OpenGLTexture* tex, u32 idx)
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
tex->SetState(GPUTexture::State::Dirty); tex->SetState(GPUTexture::State::Dirty);
} }
break;
case GPUTexture::State::Dirty: case GPUTexture::State::Dirty:
break; break;

View file

@ -23,7 +23,7 @@ ShaderGen::ShaderGen(RenderAPI render_api, GPUShaderLanguage shader_language, bo
m_glsl(shader_language == GPUShaderLanguage::GLSL || shader_language == GPUShaderLanguage::GLSLES || m_glsl(shader_language == GPUShaderLanguage::GLSL || shader_language == GPUShaderLanguage::GLSLES ||
shader_language == GPUShaderLanguage::GLSLVK), shader_language == GPUShaderLanguage::GLSLVK),
m_spirv(shader_language == GPUShaderLanguage::GLSLVK), m_supports_dual_source_blend(supports_dual_source_blend), m_spirv(shader_language == GPUShaderLanguage::GLSLVK), m_supports_dual_source_blend(supports_dual_source_blend),
m_supports_framebuffer_fetch(supports_framebuffer_fetch), m_use_glsl_interface_blocks(false) m_supports_framebuffer_fetch(supports_framebuffer_fetch)
{ {
if (m_glsl) if (m_glsl)
{ {

View file

@ -72,8 +72,8 @@ protected:
bool m_spirv; bool m_spirv;
bool m_supports_dual_source_blend; bool m_supports_dual_source_blend;
bool m_supports_framebuffer_fetch; bool m_supports_framebuffer_fetch;
bool m_use_glsl_interface_blocks; bool m_use_glsl_interface_blocks = false;
bool m_use_glsl_binding_layout; bool m_use_glsl_binding_layout = false;
bool m_has_uniform_buffer = false; bool m_has_uniform_buffer = false;
TinyString m_glsl_version_string; TinyString m_glsl_version_string;