diff --git a/Common/Data/Text/Parsers.cpp b/Common/Data/Text/Parsers.cpp index a4174c4818..41f611be84 100644 --- a/Common/Data/Text/Parsers.cpp +++ b/Common/Data/Text/Parsers.cpp @@ -7,7 +7,6 @@ // Not strictly a parser... void NiceSizeFormat(uint64_t size, char *out, size_t bufSize) { - const char *sizes[] = { "B","KB","MB","GB","TB","PB","EB" }; int s = 0; int frac = 0; while (size >= 1024) { @@ -18,8 +17,10 @@ void NiceSizeFormat(uint64_t size, char *out, size_t bufSize) { float f = (float)size + ((float)frac / 1024.0f); if (s == 0) snprintf(out, bufSize, "%d B", (int)size); - else + else { + const char* sizes[] = { "B","KB","MB","GB","TB","PB","EB" }; snprintf(out, bufSize, "%3.2f %s", f, sizes[s]); + } } std::string NiceSizeFormat(uint64_t size) { diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 184f45ebfd..a431272bc3 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -519,8 +519,8 @@ bool CreateDir(const Path &path) { // Convert it to a "CreateDirIn" call, if possible, since that's // what we can do with the storage API. AndroidContentURI uri(path.ToString()); - std::string newDirName = uri.GetLastPart(); if (uri.NavigateUp()) { + std::string newDirName = uri.GetLastPart(); INFO_LOG(COMMON, "Calling Android_CreateDirectory(%s, %s)", uri.ToString().c_str(), newDirName.c_str()); return Android_CreateDirectory(uri.ToString(), newDirName) == StorageError::SUCCESS; } else { diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 6091b73ef3..f9c0ba221c 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -35,9 +35,9 @@ bool LoadRemoteFileList(const Path &url, const std::string &userAgent, bool *can } // Start by requesting the list of files from the server. - http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8"); if (http.Resolve(baseURL.Host().c_str(), baseURL.Port())) { if (http.Connect(2, 20.0, cancel)) { + http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8"); net::RequestProgress progress(cancel); code = http.GET(req, &result, responseHeaders, &progress); http.Disconnect(); diff --git a/Common/OSVersion.cpp b/Common/OSVersion.cpp index f50c171094..ee35ef7c4e 100644 --- a/Common/OSVersion.cpp +++ b/Common/OSVersion.cpp @@ -159,10 +159,10 @@ std::string GetWindowsVersion() { // Start from higher to lower for (auto release = rbegin(windowsReleases); release != rend(windowsReleases); ++release) { - std::string previewText = release->first; WindowsReleaseInfo releaseInfo = release->second; bool buildMatch = DoesVersionMatchWindows(releaseInfo); if (buildMatch) { + std::string previewText = release->first; return previewText; } } diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 2f70fd9810..d1b1f1abbe 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -333,7 +333,6 @@ void SliderPopupScreen::UpdateTextBox() { void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; UIContext &dc = *screenManager()->getUIContext(); - auto di = GetI18NCategory(I18NCat::DIALOG); sliderValue_ = *value_; if (disabled_ && sliderValue_ < 0) @@ -362,6 +361,7 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor); if (defaultValue_ != NO_DEFAULT_FLOAT) { + auto di = GetI18NCategory(I18NCat::DIALOG); lin->Add(new Button(di->T("Reset")))->OnClick.Add([=](UI::EventParams &) { sliderValue_ = defaultValue_; changing_ = true; @@ -381,7 +381,6 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; UIContext &dc = *screenManager()->getUIContext(); - auto di = GetI18NCategory(I18NCat::DIALOG); sliderValue_ = *value_; LinearLayout *vert = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(UI::Margins(10, 10)))); @@ -406,6 +405,7 @@ void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor); if (defaultValue_ != NO_DEFAULT_FLOAT) { + auto di = GetI18NCategory(I18NCat::DIALOG); lin->Add(new Button(di->T("Reset")))->OnClick.Add([=](UI::EventParams &) { sliderValue_ = defaultValue_; if (liveUpdate_) { diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 927d8bdb4a..f7bdef840f 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -421,8 +421,8 @@ void PopupScreen::CreateViews() { box_->SetDropShadowExpand(std::max(g_display.dp_xres, g_display.dp_yres)); box_->SetSpacing(0.0f); - View *title = new PopupHeader(title_); if (HasTitleBar()) { + View* title = new PopupHeader(title_); box_->Add(title); } diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index c1802db9e7..55143dcf4f 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -239,7 +239,6 @@ int PSPNetconfDialog::Update(int animSpeed) { UpdateButtons(); UpdateCommon(); auto di = GetI18NCategory(I18NCat::DIALOG); - auto err = GetI18NCategory(I18NCat::ERRORS); u64 now = (u64)(time_now_d() * 1000000.0); // It seems JPCSP doesn't check for NETCONF_STATUS_APNET @@ -250,6 +249,7 @@ int PSPNetconfDialog::Update(int animSpeed) { StartDraw(); if (!hideNotice) { + auto err = GetI18NCategory(I18NCat::ERRORS); const float WRAP_WIDTH = 254.0f; const int confirmBtn = GetConfirmButton(); const int cancelBtn = GetCancelButton(); diff --git a/Core/Dialog/PSPNpSigninDialog.cpp b/Core/Dialog/PSPNpSigninDialog.cpp index 9af12480c9..22caaf2c9d 100644 --- a/Core/Dialog/PSPNpSigninDialog.cpp +++ b/Core/Dialog/PSPNpSigninDialog.cpp @@ -235,11 +235,11 @@ int PSPNpSigninDialog::Update(int animSpeed) { UpdateButtons(); UpdateCommon(); - auto di = GetI18NCategory(I18NCat::DIALOG); auto err = GetI18NCategory(I18NCat::ERRORS); u64 now = (u64)(time_now_d() * 1000000.0); if (request.npSigninStatus == NP_SIGNIN_STATUS_NONE) { + auto di = GetI18NCategory(I18NCat::DIALOG); UpdateFade(animSpeed); StartDraw(); diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 8a82b3ab35..024a2584b1 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1391,10 +1391,10 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param) const std::string saveDir = savePath + GetGameName(param) + GetSaveName(param); bool exists = false; - auto listing = pspFileSystem.GetDirListing(saveDir, &exists); if (param->sizeInfo.IsValid()) { + auto listing = pspFileSystem.GetDirListing(saveDir, &exists); const u64 freeBytes = MemoryStick_FreeSpace(); s64 overwriteBytes = 0; diff --git a/Core/FileSystems/BlockDevices.cpp b/Core/FileSystems/BlockDevices.cpp index b5a1ca0a8a..03fca8d221 100644 --- a/Core/FileSystems/BlockDevices.cpp +++ b/Core/FileSystems/BlockDevices.cpp @@ -66,8 +66,8 @@ BlockDevice *constructBlockDevice(FileLoader *fileLoader) { } void BlockDevice::NotifyReadError() { - auto err = GetI18NCategory(I18NCat::ERRORS); if (!reportedError_) { + auto err = GetI18NCategory(I18NCat::ERRORS); g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Game disc read error - ISO corrupt"), fileLoader_->GetPath().ToVisualString(), 6.0f); reportedError_ = true; } diff --git a/Core/HLE/Plugins.cpp b/Core/HLE/Plugins.cpp index 745d747a54..a5bb60599e 100644 --- a/Core/HLE/Plugins.cpp +++ b/Core/HLE/Plugins.cpp @@ -180,8 +180,6 @@ bool Load() { auto sy = GetI18NCategory(I18NCat::SYSTEM); for (const std::string &filename : prxPlugins) { - std::string shortName = Path(filename).GetFilename(); - std::string error_string = ""; SceUID module = KernelLoadModule(filename, &error_string); if (!error_string.empty() || module < 0) { @@ -193,6 +191,7 @@ bool Load() { if (ret < 0) { ERROR_LOG(SYSTEM, "Unable to start plugin %s: %08x", filename.c_str(), ret); } else { + std::string shortName = Path(filename).GetFilename(); g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(sy->T("Loaded plugin: %1"), shortName)); started = true; } diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 32ad2b4bfb..7863551efb 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1312,7 +1312,6 @@ void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count) { void sendChat(const std::string &chatString) { SceNetAdhocctlChatPacketC2S chat; - auto n = GetI18NCategory(I18NCat::NETWORKING); chat.base.opcode = OPCODE_CHAT; //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected if (friendFinderRunning) { @@ -1334,6 +1333,7 @@ void sendChat(const std::string &chatString) { } } else { std::lock_guard guard(chatLogLock); + auto n = GetI18NCategory(I18NCat::NETWORKING); chatLog.push_back(n->T("You're in Offline Mode, go to lobby or online hall")); chatMessageGeneration++; } diff --git a/Core/HLE/sceAudiocodec.cpp b/Core/HLE/sceAudiocodec.cpp index 3c9643d897..296b5bf90e 100644 --- a/Core/HLE/sceAudiocodec.cpp +++ b/Core/HLE/sceAudiocodec.cpp @@ -100,8 +100,6 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) { } if (IsValidCodec(codec)){ - // Use SimpleAudioDec to decode audio - auto ctx = PSPPointer::Create(ctxPtr); // On stack, no need to allocate. int outbytes = 0; // find a decoder in audioList auto decoder = findDecoder(ctxPtr); @@ -115,6 +113,8 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) { } if (decoder != NULL) { + // Use SimpleAudioDec to decode audio + auto ctx = PSPPointer::Create(ctxPtr); // On stack, no need to allocate. // Decode audio decoder->Decode(Memory::GetPointer(ctx->inDataPtr), ctx->inDataSize, Memory::GetPointerWrite(ctx->outDataPtr), &outbytes); } diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 7259bd2d8d..cb729b672d 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -519,10 +519,10 @@ public: fontMap.erase(fonts_[i]); } } - u32 args[2] = { userDataAddr(), (u32)handle_ }; // TODO: The return value of this is leaking. if (handle_) { // Avoid calling free-callback on double-free if (coreState != CORE_POWERDOWN) { + u32 args[2] = { userDataAddr(), (u32)handle_ }; hleEnqueueCall(freeFuncAddr(), 2, args); } } diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index c8fbbff1d1..bd61e25b75 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -2164,7 +2164,6 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr) { - auto smoption = PSPPointer::Create(optionAddr); u32 error; PSPModule *module = kernelObjects.Get(moduleId, error); if (!module) { @@ -2190,6 +2189,7 @@ static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 ret moduleId,argsize,argAddr,returnValueAddr,optionAddr); bool needsWait; + auto smoption = PSPPointer::Create(optionAddr); int ret = KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait); if (needsWait) { diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 1cdeeb00ba..da8fe13a39 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1179,10 +1179,10 @@ skip: void FinalizeScan(bool insertSymbols) { HashFunctions(); - Path hashMapFilename = GetSysDirectory(DIRECTORY_SYSTEM) / "knownfuncs.ini"; if (g_Config.bFuncHashMap || g_Config.bFuncReplacements) { LoadBuiltinHashMap(); if (g_Config.bFuncHashMap) { + Path hashMapFilename = GetSysDirectory(DIRECTORY_SYSTEM) / "knownfuncs.ini"; LoadHashMap(hashMapFilename); StoreHashMap(hashMapFilename); } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 80563be08d..aee5fb42b3 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -364,7 +364,6 @@ namespace SaveState } // Memory is a bit tricky when jit is enabled, since there's emuhacks in it. - auto savedReplacements = SaveAndClearReplacements(); if (MIPSComp::jit && p.mode == p.MODE_WRITE) { std::lock_guard guard(MIPSComp::jitLock); if (MIPSComp::jit) { @@ -385,8 +384,10 @@ namespace SaveState // Don't bother restoring if reading, we'll deal with that in KernelModuleDoState. // In theory, different functions might have been runtime loaded in the state. - if (p.mode != p.MODE_READ) + if (p.mode != p.MODE_READ) { + auto savedReplacements = SaveAndClearReplacements(); RestoreSavedReplacements(savedReplacements); + } MemoryStick_DoState(p); currentMIPS->DoState(p); @@ -598,18 +599,20 @@ namespace SaveState Load(fn, slot, callback, cbUserData); } } else { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData); + } } } bool UndoLoad(const Path &gameFilename, Callback callback, void *cbUserData) { if (g_Config.sStateLoadUndoGame != GenerateFullDiscId(gameFilename)) { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Error: load undo state is from a different game"), cbUserData); + } return false; } @@ -618,9 +621,10 @@ namespace SaveState Load(fn, LOAD_UNDO_SLOT, callback, cbUserData); return true; } else { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Failed to load state for load undo. Error in the file system."), cbUserData); + } return false; } } @@ -628,10 +632,9 @@ namespace SaveState void SaveSlot(const Path &gameFilename, int slot, Callback callback, void *cbUserData) { Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION); - Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION); - Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); if (!fn.empty()) { + Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); auto renameCallback = [=](Status status, const std::string &message, void *data) { if (status != Status::FAILURE) { if (g_Config.bEnableStateUndo) { @@ -651,26 +654,28 @@ namespace SaveState }; // Let's also create a screenshot. if (g_Config.bEnableStateUndo) { + Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); DeleteIfExists(shotUndo); RenameIfExists(shot, shotUndo); } SaveScreenshot(shot, Callback(), 0); Save(fn.WithExtraExtension(".tmp"), slot, renameCallback, cbUserData); } else { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData); + } } } - bool UndoSaveSlot(const Path &gameFilename, int slot) { - Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION); - Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); + bool UndoSaveSlot(const Path &gameFilename, int slot) { Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION); - Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); // Do nothing if there's no undo. if (File::Exists(fnUndo)) { + Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION); + Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); + Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); // Swap them so they can undo again to redo. Mistakes happen. SwapIfExists(shotUndo, shot); SwapIfExists(fnUndo, fn); diff --git a/Core/Util/DisArm64.cpp b/Core/Util/DisArm64.cpp index 050589f2f0..5fc2a6eba9 100644 --- a/Core/Util/DisArm64.cpp +++ b/Core/Util/DisArm64.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "Common/Arm64Emitter.h" #include "Common/StringUtils.h" @@ -496,7 +497,7 @@ static void DataProcessingRegister(uint32_t w, uint64_t addr, Instruction *instr int op31 = (w >> 21) & 0x7; int o0 = (w >> 15) & 1; int Ra = (w >> 10) & 0x1f; - const char *opnames[8] = { 0, 0, "maddl", "msubl", "smulh", 0, 0, 0 }; + static constexpr std::array opnames = { 0, 0, "maddl", "msubl", "smulh", 0, 0, 0 }; if (op31 == 0) { // madd/msub supports both 32-bit and 64-bit modes