Merge pull request #13461 from JoshuaVandaele/warningsbegone

Fix shadowed variable warnings and missing declarations
This commit is contained in:
JosJuice 2025-03-28 18:43:09 +01:00 committed by GitHub
commit c7ede8a6b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 21 deletions

View file

@ -336,8 +336,8 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string&
char name[512]{}; char name[512]{};
static constexpr char ENTRY_OF_STRING[] = " (entry of "; static constexpr char ENTRY_OF_STRING[] = " (entry of ";
static constexpr std::string_view ENTRY_OF_VIEW(ENTRY_OF_STRING); static constexpr std::string_view ENTRY_OF_VIEW(ENTRY_OF_STRING);
auto parse_entry_of = [](char* name) { auto parse_entry_of = [](char* name_buf) {
if (char* s1 = strstr(name, ENTRY_OF_STRING); s1 != nullptr) if (char* s1 = strstr(name_buf, ENTRY_OF_STRING); s1 != nullptr)
{ {
char container[512]; char container[512];
char* ptr = s1 + ENTRY_OF_VIEW.size(); char* ptr = s1 + ENTRY_OF_VIEW.size();
@ -350,17 +350,17 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string&
strcpy(s1, ptr); strcpy(s1, ptr);
*s2 = '\0'; *s2 = '\0';
strcat(container, "::"); strcat(container, "::");
strcat(container, name); strcat(container, name_buf);
strcpy(name, container); strcpy(name_buf, container);
} }
} }
}; };
auto was_alignment = [](const char* name) { auto was_alignment = [](const char* name_buf) {
return *name == ' ' || (*name >= '0' && *name <= '9'); return *name_buf == ' ' || (*name_buf >= '0' && *name_buf <= '9');
}; };
auto parse_alignment = [](char* name, u32* alignment) { auto parse_alignment = [](char* name_buf, u32* alignment_buf) {
const std::string buffer(StripWhitespace(name)); const std::string buffer(StripWhitespace(name_buf));
return sscanf(buffer.c_str(), "%i %511[^\r\n]", alignment, name); return sscanf(buffer.c_str(), "%i %511[^\r\n]", alignment_buf, name_buf);
}; };
switch (column_count) 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 // Save symbol map similar to CodeWarrior's map file
bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const
{ {
File::IOFile f(filename, "w"); File::IOFile file(filename, "w");
if (!f) if (!file)
return false; return false;
// Write .text section // Write .text section
@ -464,7 +464,7 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const
m_functions | m_functions |
std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Function; }) | std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Function; }) |
std::views::transform([](auto f) { return f.second; }); 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) for (const auto& symbol : function_symbols)
{ {
// Write symbol address, size, virtual address, alignment, name // 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()) if (!symbol.object_name.empty())
line += fmt::format(" \t{0}", symbol.object_name); line += fmt::format(" \t{0}", symbol.object_name);
line += "\n"; line += "\n";
f.WriteString(line); file.WriteString(line);
} }
// Write .data section // Write .data section
@ -482,7 +482,7 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const
m_functions | m_functions |
std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Data; }) | std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Data; }) |
std::views::transform([](auto f) { return f.second; }); 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) for (const auto& symbol : data_symbols)
{ {
// Write symbol address, size, virtual address, alignment, name // 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()) if (!symbol.object_name.empty())
line += fmt::format(" \t{0}", symbol.object_name); line += fmt::format(" \t{0}", symbol.object_name);
line += "\n"; line += "\n";
f.WriteString(line); file.WriteString(line);
} }
return true; return true;

View file

@ -469,7 +469,7 @@ void SetDepth(u16 x, u16 y, u32 depth)
SetPixelDepth(GetDepthOffset(x, y), depth); SetPixelDepth(GetDepthOffset(x, y), depth);
} }
u32 GetColor(u16 x, u16 y) static u32 GetColor(u16 x, u16 y)
{ {
u32 offset = GetColorOffset(x, y); u32 offset = GetColorOffset(x, y);
return GetPixelColor(offset); return GetPixelColor(offset);
@ -544,7 +544,7 @@ static yuv444 ConvertColorToYUV(u32 color)
return {y_round, u_round, v_round}; 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); u32 offset = GetDepthOffset(x, y);
return GetPixelDepth(offset); return GetPixelDepth(offset);

View file

@ -138,12 +138,13 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale)
if (window_min_x > window_max_x || window_min_y > window_max_y) if (window_min_x > window_max_x || window_min_y > window_max_y)
return; return;
const float window_x = std::clamp(position.x, window_min_x, window_max_x); const float clamped_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 float clamped_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 bool window_needs_clamping =
(clamped_window_x != position.x) || (clamped_window_y != position.y);
if (window_needs_clamping) 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; const float graph_width = 50.f * backbuffer_scale + 3.f * window_width + 2.f * window_padding;