From 62740d97a83b6035e1c783b9cf9ae786e358b4ee Mon Sep 17 00:00:00 2001 From: Lioncache Date: Mon, 18 Dec 2023 10:20:26 -0500 Subject: [PATCH] Core/DSP/DSPTables: Make use of fmt::format in pdname() Resolves a deprecation warning on macOS. Also, we can convert the function to just return a std::string instead of using a static internal buffer, which is gross and thread-unsafe. --- Source/Core/Core/DSP/DSPTables.cpp | 9 ++++----- Source/Core/Core/DSP/DSPTables.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/DSP/DSPTables.cpp b/Source/Core/Core/DSP/DSPTables.cpp index cb8a224396..191f8b3622 100644 --- a/Source/Core/Core/DSP/DSPTables.cpp +++ b/Source/Core/Core/DSP/DSPTables.cpp @@ -10,6 +10,8 @@ #include #include +#include + #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" @@ -492,18 +494,15 @@ const std::array regnames = }}; // clang-format on -const char* pdname(u16 val) +std::string pdname(u16 val) { - static char tmpstr[12]; // nasty - for (const pdlabel_t& pdlabel : pdlabels) { if (pdlabel.addr == val) return pdlabel.name; } - sprintf(tmpstr, "0x%04x", val); - return tmpstr; + return fmt::format("0x{:04x}", val); } const char* pdregname(int val) diff --git a/Source/Core/Core/DSP/DSPTables.h b/Source/Core/Core/DSP/DSPTables.h index e2a90d8e7f..8dead3acad 100644 --- a/Source/Core/Core/DSP/DSPTables.h +++ b/Source/Core/Core/DSP/DSPTables.h @@ -93,7 +93,7 @@ struct pdlabel_t extern const std::array regnames; extern const std::array pdlabels; -const char* pdname(u16 val); +std::string pdname(u16 val); const char* pdregname(int val); const char* pdregnamelong(int val);