From fec708489a9f15a7c08b4fb52eb3d3f20015be62 Mon Sep 17 00:00:00 2001 From: lainon Date: Fri, 30 Sep 2022 12:26:30 +0300 Subject: [PATCH] Correct cleaning string and remove unused vars --- Common/Data/Encoding/Compression.cpp | 1 - Common/File/Path.cpp | 1 - Common/GPU/D3D9/D3D9ShaderCompiler.cpp | 2 +- Common/GPU/ShaderTranslation.cpp | 2 +- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 4 ---- Core/Config.cpp | 8 ++++---- Core/Core.cpp | 6 +++--- Core/Debugger/DisassemblyManager.cpp | 8 ++++---- Core/Debugger/WebSocket/WebSocketUtils.cpp | 2 +- Core/Dialog/SavedataParam.cpp | 2 +- Core/FileSystems/ISOFileSystem.cpp | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 1 - Core/Loaders.cpp | 2 +- Core/MIPS/MIPSAsm.cpp | 2 +- Core/System.cpp | 2 +- Core/Util/GameManager.cpp | 2 +- Core/WebServer.cpp | 2 +- GPU/Common/PostShader.cpp | 4 ++-- GPU/Common/TextureCacheCommon.cpp | 2 -- UI/CwCheatScreen.cpp | 1 - UI/EmuScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- UI/Store.cpp | 2 +- UI/TextureUtil.cpp | 4 ++-- Windows/Debugger/CtrlDisAsmView.cpp | 2 +- Windows/Debugger/CtrlMemView.cpp | 2 +- Windows/InputBox.cpp | 4 ++-- Windows/MainWindowMenu.cpp | 2 +- Windows/main.cpp | 2 +- android/jni/TestRunner.cpp | 4 ++-- headless/Headless.cpp | 2 +- unittest/UnitTest.cpp | 2 +- 32 files changed, 38 insertions(+), 48 deletions(-) diff --git a/Common/Data/Encoding/Compression.cpp b/Common/Data/Encoding/Compression.cpp index 751a9595cf..3e2e499a18 100644 --- a/Common/Data/Encoding/Compression.cpp +++ b/Common/Data/Encoding/Compression.cpp @@ -95,7 +95,6 @@ bool decompress_string(const std::string& str, std::string *dest) { inflateEnd(&zs); if (ret != Z_STREAM_END) { // an error occurred that was not EOF - std::ostringstream oss; ERROR_LOG(IO, "Exception during zlib decompression: (%i) %s", ret, zs.msg); return false; } diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index ba3372e78a..dd01ac26a7 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -357,7 +357,6 @@ bool Path::ComputePathTo(const Path &other, std::string &path) const { return true; } - std::string diff; if (type_ == PathType::CONTENT_URI) { AndroidContentURI a(path_); AndroidContentURI b(other.path_); diff --git a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp index f41ea3911d..5a647196fe 100644 --- a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp +++ b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp @@ -47,7 +47,7 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std: pShaderCode = nullptr; } } else { - *errorMessage = ""; + (*errorMessage).clear(); } return pShaderCode; diff --git a/Common/GPU/ShaderTranslation.cpp b/Common/GPU/ShaderTranslation.cpp index 34de213451..84cd69afe5 100644 --- a/Common/GPU/ShaderTranslation.cpp +++ b/Common/GPU/ShaderTranslation.cpp @@ -233,7 +233,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan return false; #endif - *errorMessage = ""; + (*errorMessage).clear(); glslang::TProgram program; const char *shaderStrings[1]{}; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 428d66e2cc..3eee8f7ad7 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1348,7 +1348,6 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c int n = 0; int stage = 0; - VkImageMemoryBarrier barriers[2]{}; if (step.render.framebuffer->color.layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { recordBarrier_.TransitionImage( step.render.framebuffer->color.image, @@ -1758,9 +1757,6 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { // The barrier code doesn't handle this case. We'd need to transition to GENERAL to do an intra-image copy. _dbg_assert_(step.blit.src != step.blit.dst); - VkImageMemoryBarrier srcBarriers[2]{}; - VkImageMemoryBarrier dstBarriers[2]{}; - VKRFramebuffer *src = step.blit.src; VKRFramebuffer *dst = step.blit.dst; diff --git a/Core/Config.cpp b/Core/Config.cpp index 45e396c9b7..248bcb2852 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1424,7 +1424,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { // build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice, // even if said newer version is >= the upgrade found online. if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) { - upgradeMessage = ""; + upgradeMessage.clear(); } // Check for new version on every 10 runs. @@ -1636,16 +1636,16 @@ void Config::DownloadCompletedCallback(http::Download &download) { if (installed >= upgrade) { INFO_LOG(LOADER, "Version check: Already up to date, erasing any upgrade message"); - g_Config.upgradeMessage = ""; + g_Config.upgradeMessage.clear(); g_Config.upgradeVersion = upgrade.ToString(); - g_Config.dismissedVersion = ""; + g_Config.dismissedVersion.clear(); return; } if (installed < upgrade && dismissed != upgrade) { g_Config.upgradeMessage = "New version of PPSSPP available!"; g_Config.upgradeVersion = upgrade.ToString(); - g_Config.dismissedVersion = ""; + g_Config.dismissedVersion.clear(); } } diff --git a/Core/Core.cpp b/Core/Core.cpp index 52a1df8f4c..c1bb28cefd 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -447,7 +447,7 @@ void Core_MemoryException(u32 address, u32 pc, MemoryExceptionType type) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::MEMORY; - e.info = ""; + e.info.clear(); e.memory_type = type; e.address = address; e.pc = pc; @@ -483,7 +483,7 @@ void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::BAD_EXEC_ADDR; - e.info = ""; + e.info.clear(); e.exec_type = type; e.address = address; e.pc = pc; @@ -498,7 +498,7 @@ void Core_Break(u32 pc) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::BREAK; - e.info = ""; + e.info.clear(); e.pc = pc; if (!g_Config.bIgnoreBadMemAccess) { diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 511aeee82a..ab0e10aa9b 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -316,7 +316,7 @@ void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLin dest.params = "Disassembly failure"; } else { dest.name = "-"; - dest.params = ""; + dest.params.clear(); } } @@ -1003,7 +1003,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = pos-1; inString = false; } @@ -1028,7 +1028,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = pos-1; inString = false; } @@ -1099,7 +1099,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = currentPos; } diff --git a/Core/Debugger/WebSocket/WebSocketUtils.cpp b/Core/Debugger/WebSocket/WebSocketUtils.cpp index cc49e33336..8d6be87b9e 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.cpp +++ b/Core/Debugger/WebSocket/WebSocketUtils.cpp @@ -262,7 +262,7 @@ bool DebuggerRequest::ParamString(const char *name, std::string *out, DebuggerPa return true; } else if (tag == JSON_NULL) { if (required) { - *out = ""; + (*out).clear(); } return true; } else if (tag == JSON_NUMBER) { diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 5a04ebc882..a4f437d40c 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -258,7 +258,7 @@ std::string SavedataParam::GetSaveFilePath(const SceUtilitySavedataParam *param, inline static std::string FixedToString(const char *str, size_t n) { if (!str) { - return std::string(""); + return std::string(); } else { return std::string(str, strnlen(str, n)); } diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index a873f3f19b..0d57bf2848 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -148,7 +148,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic if (!blockDevice->ReadBlock(16, (u8*)&desc)) blockDevice->NotifyReadError(); - entireISO.name = ""; + entireISO.name.clear(); entireISO.isDirectory = false; entireISO.startingPosition = 0; entireISO.size = _blockDevice->GetNumBlocks(); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index dd41e95855..c3a339172d 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -81,7 +81,6 @@ void VirtualDiscFileSystem::LoadFileListIndex() { return; } - std::string buf; static const int MAX_LINE_SIZE = 2048; char linebuf[MAX_LINE_SIZE]{}; while (fgets(linebuf, MAX_LINE_SIZE, f)) { diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 09ac48f47f..02625a16c5 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -60,7 +60,7 @@ FileLoader *ConstructFileLoader(const Path &filename) { // TODO : improve, look in the file more IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) { - *errorString = ""; + (*errorString).clear(); if (fileLoader == nullptr) { *errorString = "Invalid fileLoader"; return IdentifiedFileType::ERROR_IDENTIFYING; diff --git a/Core/MIPS/MIPSAsm.cpp b/Core/MIPS/MIPSAsm.cpp index 97d34a4f18..f95d0d1fc0 100644 --- a/Core/MIPS/MIPSAsm.cpp +++ b/Core/MIPS/MIPSAsm.cpp @@ -79,7 +79,7 @@ bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address) g_symbolMap->GetLabels(args.labels); } - errorText = L""; + errorText.clear(); if (!runArmips(args)) { for (size_t i = 0; i < errors.size(); i++) diff --git a/Core/System.cpp b/Core/System.cpp index 9c7519edd6..7f96ffb7c5 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -426,7 +426,7 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) { if (g_CoreParameter.graphicsContext == nullptr) { g_CoreParameter.graphicsContext = temp; } - g_CoreParameter.errorString = ""; + g_CoreParameter.errorString.clear(); pspIsIniting = true; PSP_SetLoading("Loading game..."); diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index b6f4ccbd65..e808f07b6c 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -674,7 +674,7 @@ bool GameManager::InstallRawISO(const Path &file, const std::string &originalNam void GameManager::ResetInstallError() { if (!installInProgress_) { - installError_ = ""; + installError_.clear(); } } diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 3d6d9b37cb..4aff212eba 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -297,7 +297,7 @@ static void ForwardDebuggerRequest(const http::Request &request) { // Check if this is a websocket request... std::string upgrade; if (!request.GetHeader("upgrade", &upgrade)) { - upgrade = ""; + upgrade.clear(); } // Yes - proceed with the socket. diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index ed86397521..ad02d603b4 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -55,7 +55,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct off.name = "Off"; off.section = "Off"; for (size_t i = 0; i < ARRAY_SIZE(off.settings); ++i) { - off.settings[i].name = ""; + off.settings[i].name.clear(); off.settings[i].value = 0.0f; off.settings[i].minValue = -1.0f; off.settings[i].maxValue = 1.0f; @@ -174,7 +174,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct section.Get("UsePreviousFrame", &info.usePreviousFrame, false); if (info.parent == "Off") - info.parent = ""; + info.parent.clear(); for (size_t i = 0; i < ARRAY_SIZE(info.settings); ++i) { auto &setting = info.settings[i]; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 1b7d8d5986..d30a82d7b8 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -867,8 +867,6 @@ void TextureCacheCommon::NotifyFramebuffer(VirtualFramebuffer *framebuffer, Fram // Try to match the new framebuffer to existing textures. // Backwards from the "usual" texturing case so can't share a utility function. - std::vector candidates; - u64 cacheKey = (u64)fb_addr << 32; // If it has a clut, those are the low 32 bits, so it'll be inside this range. // Also, if it's a subsample of the buffer, it'll also be within the FBO. diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 8b4ba9d146..dee7a11166 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -199,7 +199,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) { WARN_LOG(COMMON, "CWCHEAT: Incorrect ID(%s) - can't import cheats.", gameID_.c_str()); return UI::EVENT_DONE; } - std::string line; std::vector title; std::vector newList; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 14ee1ced6c..7ed519f7c0 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1049,7 +1049,7 @@ void EmuScreen::update() { errLoadingFile.append(err->T(errorMessage_.c_str())); screenManager()->push(new PromptScreen(errLoadingFile, "OK", "")); - errorMessage_ = ""; + errorMessage_.clear(); quit_ = true; return; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0c1c0d009e..d58e23c704 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1488,7 +1488,7 @@ void GameSettingsScreen::TriggerRestart(const char *why) { std::string param = "--gamesettings"; if (editThenRestore_) { // We won't pass the gameID, so don't resume back into settings. - param = ""; + param.clear(); } else if (!gamePath_.empty()) { param += " \"" + ReplaceAll(ReplaceAll(gamePath_.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\""; } diff --git a/UI/Store.cpp b/UI/Store.cpp index 8329ed22d9..86a084da95 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -502,7 +502,7 @@ void StoreScreen::CreateViews() { selectedItem->Press(); } else { - lastSelectedName_ = ""; + lastSelectedName_.clear(); } } root_->Add(content); diff --git a/UI/TextureUtil.cpp b/UI/TextureUtil.cpp index 9a5b377a90..80dfb59e1a 100644 --- a/UI/TextureUtil.cpp +++ b/UI/TextureUtil.cpp @@ -151,7 +151,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ size_t fileSize; uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize); if (!buffer) { - filename_ = ""; + filename_.clear(); ERROR_LOG(IO, "Failed to read file '%s'", filename.c_str()); return false; } @@ -159,7 +159,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ if (retval) { filename_ = filename; } else { - filename_ = ""; + filename_.clear(); ERROR_LOG(IO, "Failed to load texture '%s'", filename.c_str()); } delete[] buffer; diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 5aca43fbcf..242fb60af5 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -191,7 +191,7 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) matchAddress = -1; searching = false; - searchQuery = ""; + searchQuery.clear(); windowStart = curAddress; whiteBackground = false; displaySymbols = true; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index c8f8a3f8df..e5af6aaa8d 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -49,7 +49,7 @@ CtrlMemView::CtrlMemView(HWND _wnd) curAddress = 0; debugger = 0; - searchQuery = ""; + searchQuery.clear(); matchAddress = -1; searching = false; diff --git a/Windows/InputBox.cpp b/Windows/InputBox.cpp index 1d4fd02e7e..632a8134fe 100644 --- a/Windows/InputBox.cpp +++ b/Windows/InputBox.cpp @@ -49,12 +49,12 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, con if (defaultValue.size() < 255) textBoxContents = ConvertUTF8ToWString(defaultValue); else - textBoxContents = L""; + textBoxContents.clear(); if (title != NULL) windowTitle = title; else - windowTitle = L""; + windowTitle.clear(); if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) { outvalue = ConvertWStringToUTF8(out); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 6aba9d275a..384bb9a0f7 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -911,7 +911,7 @@ namespace MainWindow { if (lastSlash) { fn = lastSlash + 1; } else { - fn = ""; + fn.clear(); } PSPFileInfo info = pspFileSystem.GetFileInfo(filename); diff --git a/Windows/main.cpp b/Windows/main.cpp index e3888dfe4c..90e216f283 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -211,7 +211,7 @@ std::string System_GetProperty(SystemProperty prop) { if (wstr) retval = ConvertWStringToUTF8(wstr); else - retval = ""; + retval.clear(); GlobalUnlock(handle); CloseClipboard(); } diff --git a/android/jni/TestRunner.cpp b/android/jni/TestRunner.cpp index d032a9db75..64e6f7761c 100644 --- a/android/jni/TestRunner.cpp +++ b/android/jni/TestRunner.cpp @@ -107,7 +107,7 @@ bool RunTests() { // Never report from tests. std::string savedReportHost = g_Config.sReportHost; - g_Config.sReportHost = ""; + g_Config.sReportHost.clear(); for (size_t i = 0; i < ARRAY_SIZE(testsToRun); i++) { std::string testName = testsToRun[i]; @@ -116,7 +116,7 @@ bool RunTests() { INFO_LOG(SYSTEM, "Preparing to execute '%s'", testName.c_str()); std::string error_string; - output = ""; + output.clear(); if (!PSP_Init(coreParam, &error_string)) { ERROR_LOG(SYSTEM, "Failed to init unittest %s : %s", testsToRun[i], error_string.c_str()); PSP_CoreParameter().pixelWidth = pixel_xres; diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 1deebd95cd..dcfad07e8d 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -411,7 +411,7 @@ int main(int argc, const char* argv[]) g_Config.bFirstRun = false; g_Config.bIgnoreBadMemAccess = true; // Never report from tests. - g_Config.sReportHost = ""; + g_Config.sReportHost.clear(); g_Config.bAutoSaveSymbolMap = false; g_Config.iRenderingMode = FB_BUFFERED_MODE; g_Config.bHardwareTransform = true; diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 4f8239a11b..bb3d9d112b 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -634,7 +634,7 @@ static bool TestPath() { Path path3 = path2 / "foo/bar"; EXPECT_EQ_STR(path3.WithExtraExtension(".txt").ToString(), std::string("/asdf/jkl/foo/bar.txt")); - EXPECT_EQ_STR(Path("foo.bar/hello").GetFileExtension(), std::string("")); + EXPECT_EQ_STR(Path("foo.bar/hello").GetFileExtension(), std::string()); EXPECT_EQ_STR(Path("foo.bar/hello.txt").WithReplacedExtension(".txt", ".html").ToString(), std::string("foo.bar/hello.html")); EXPECT_EQ_STR(Path("C:\\Yo").NavigateUp().ToString(), std::string("C:"));