From 3a1a60d4f8ac79588d4b6f8197131ea45ae53d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Thu, 27 Mar 2025 21:20:20 +0100 Subject: [PATCH] Fix shadowed variable warnings and missing declarations - PPCSymbolDB: Resolve shadowed variable warnings - PerformanceMetrics: Resolve shadowed variable warnings - SWEfbInterface: Add missing declarations --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 30 +++++++++---------- .../VideoBackends/Software/SWEfbInterface.cpp | 4 +-- .../Core/VideoCommon/PerformanceMetrics.cpp | 9 +++--- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 6c686148f3..5351d1ec28 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -336,8 +336,8 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string& char name[512]{}; static constexpr char ENTRY_OF_STRING[] = " (entry of "; static constexpr std::string_view ENTRY_OF_VIEW(ENTRY_OF_STRING); - auto parse_entry_of = [](char* name) { - if (char* s1 = strstr(name, ENTRY_OF_STRING); s1 != nullptr) + auto parse_entry_of = [](char* name_buf) { + if (char* s1 = strstr(name_buf, ENTRY_OF_STRING); s1 != nullptr) { char container[512]; char* ptr = s1 + ENTRY_OF_VIEW.size(); @@ -350,17 +350,17 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string& strcpy(s1, ptr); *s2 = '\0'; strcat(container, "::"); - strcat(container, name); - strcpy(name, container); + strcat(container, name_buf); + strcpy(name_buf, container); } } }; - auto was_alignment = [](const char* name) { - return *name == ' ' || (*name >= '0' && *name <= '9'); + auto was_alignment = [](const char* name_buf) { + return *name_buf == ' ' || (*name_buf >= '0' && *name_buf <= '9'); }; - auto parse_alignment = [](char* name, u32* alignment) { - const std::string buffer(StripWhitespace(name)); - return sscanf(buffer.c_str(), "%i %511[^\r\n]", alignment, name); + auto parse_alignment = [](char* name_buf, u32* alignment_buf) { + const std::string buffer(StripWhitespace(name_buf)); + return sscanf(buffer.c_str(), "%i %511[^\r\n]", alignment_buf, name_buf); }; switch (column_count) { @@ -455,8 +455,8 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string& // Save symbol map similar to CodeWarrior's map file bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const { - File::IOFile f(filename, "w"); - if (!f) + File::IOFile file(filename, "w"); + if (!file) return false; // Write .text section @@ -464,7 +464,7 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const m_functions | std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Function; }) | std::views::transform([](auto f) { return f.second; }); - f.WriteString(".text section layout\n"); + file.WriteString(".text section layout\n"); for (const auto& symbol : function_symbols) { // Write symbol address, size, virtual address, alignment, name @@ -474,7 +474,7 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const if (!symbol.object_name.empty()) line += fmt::format(" \t{0}", symbol.object_name); line += "\n"; - f.WriteString(line); + file.WriteString(line); } // Write .data section @@ -482,7 +482,7 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const m_functions | std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Data; }) | std::views::transform([](auto f) { return f.second; }); - f.WriteString("\n.data section layout\n"); + file.WriteString("\n.data section layout\n"); for (const auto& symbol : data_symbols) { // Write symbol address, size, virtual address, alignment, name @@ -492,7 +492,7 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const if (!symbol.object_name.empty()) line += fmt::format(" \t{0}", symbol.object_name); line += "\n"; - f.WriteString(line); + file.WriteString(line); } return true; diff --git a/Source/Core/VideoBackends/Software/SWEfbInterface.cpp b/Source/Core/VideoBackends/Software/SWEfbInterface.cpp index e534fab1c5..d269e8435a 100644 --- a/Source/Core/VideoBackends/Software/SWEfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/SWEfbInterface.cpp @@ -469,7 +469,7 @@ void SetDepth(u16 x, u16 y, u32 depth) SetPixelDepth(GetDepthOffset(x, y), depth); } -u32 GetColor(u16 x, u16 y) +static u32 GetColor(u16 x, u16 y) { u32 offset = GetColorOffset(x, y); return GetPixelColor(offset); @@ -544,7 +544,7 @@ static yuv444 ConvertColorToYUV(u32 color) return {y_round, u_round, v_round}; } -u32 GetDepth(u16 x, u16 y) +static u32 GetDepth(u16 x, u16 y) { u32 offset = GetDepthOffset(x, y); return GetPixelDepth(offset); diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index 9f0b766dbc..db61ea8978 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -138,12 +138,13 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) if (window_min_x > window_max_x || window_min_y > window_max_y) return; - const float window_x = std::clamp(position.x, window_min_x, window_max_x); - const float window_y = std::clamp(position.y, window_min_y, window_max_y); - const bool window_needs_clamping = (window_x != position.x) || (window_y != position.y); + const float clamped_window_x = std::clamp(position.x, window_min_x, window_max_x); + const float clamped_window_y = std::clamp(position.y, window_min_y, window_max_y); + const bool window_needs_clamping = + (clamped_window_x != position.x) || (clamped_window_y != position.y); if (window_needs_clamping) - ImGui::SetWindowPos(ImVec2(window_x, window_y), ImGuiCond_Always); + ImGui::SetWindowPos(ImVec2(clamped_window_x, clamped_window_y), ImGuiCond_Always); }; const float graph_width = 50.f * backbuffer_scale + 3.f * window_width + 2.f * window_padding;