Correct cleaning string and remove unused vars

This commit is contained in:
lainon 2022-09-30 12:26:30 +03:00
parent 89dab444c4
commit fec708489a
32 changed files with 38 additions and 48 deletions

View file

@ -95,7 +95,6 @@ bool decompress_string(const std::string& str, std::string *dest) {
inflateEnd(&zs); inflateEnd(&zs);
if (ret != Z_STREAM_END) { // an error occurred that was not EOF 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); ERROR_LOG(IO, "Exception during zlib decompression: (%i) %s", ret, zs.msg);
return false; return false;
} }

View file

@ -357,7 +357,6 @@ bool Path::ComputePathTo(const Path &other, std::string &path) const {
return true; return true;
} }
std::string diff;
if (type_ == PathType::CONTENT_URI) { if (type_ == PathType::CONTENT_URI) {
AndroidContentURI a(path_); AndroidContentURI a(path_);
AndroidContentURI b(other.path_); AndroidContentURI b(other.path_);

View file

@ -47,7 +47,7 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std:
pShaderCode = nullptr; pShaderCode = nullptr;
} }
} else { } else {
*errorMessage = ""; (*errorMessage).clear();
} }
return pShaderCode; return pShaderCode;

View file

@ -233,7 +233,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan
return false; return false;
#endif #endif
*errorMessage = ""; (*errorMessage).clear();
glslang::TProgram program; glslang::TProgram program;
const char *shaderStrings[1]{}; const char *shaderStrings[1]{};

View file

@ -1348,7 +1348,6 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
int n = 0; int n = 0;
int stage = 0; int stage = 0;
VkImageMemoryBarrier barriers[2]{};
if (step.render.framebuffer->color.layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { if (step.render.framebuffer->color.layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) {
recordBarrier_.TransitionImage( recordBarrier_.TransitionImage(
step.render.framebuffer->color.image, 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. // 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); _dbg_assert_(step.blit.src != step.blit.dst);
VkImageMemoryBarrier srcBarriers[2]{};
VkImageMemoryBarrier dstBarriers[2]{};
VKRFramebuffer *src = step.blit.src; VKRFramebuffer *src = step.blit.src;
VKRFramebuffer *dst = step.blit.dst; VKRFramebuffer *dst = step.blit.dst;

View file

@ -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, // 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. // even if said newer version is >= the upgrade found online.
if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) { if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) {
upgradeMessage = ""; upgradeMessage.clear();
} }
// Check for new version on every 10 runs. // Check for new version on every 10 runs.
@ -1636,16 +1636,16 @@ void Config::DownloadCompletedCallback(http::Download &download) {
if (installed >= upgrade) { if (installed >= upgrade) {
INFO_LOG(LOADER, "Version check: Already up to date, erasing any upgrade message"); 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.upgradeVersion = upgrade.ToString();
g_Config.dismissedVersion = ""; g_Config.dismissedVersion.clear();
return; return;
} }
if (installed < upgrade && dismissed != upgrade) { if (installed < upgrade && dismissed != upgrade) {
g_Config.upgradeMessage = "New version of PPSSPP available!"; g_Config.upgradeMessage = "New version of PPSSPP available!";
g_Config.upgradeVersion = upgrade.ToString(); g_Config.upgradeVersion = upgrade.ToString();
g_Config.dismissedVersion = ""; g_Config.dismissedVersion.clear();
} }
} }

View file

@ -447,7 +447,7 @@ void Core_MemoryException(u32 address, u32 pc, MemoryExceptionType type) {
ExceptionInfo &e = g_exceptionInfo; ExceptionInfo &e = g_exceptionInfo;
e = {}; e = {};
e.type = ExceptionType::MEMORY; e.type = ExceptionType::MEMORY;
e.info = ""; e.info.clear();
e.memory_type = type; e.memory_type = type;
e.address = address; e.address = address;
e.pc = pc; e.pc = pc;
@ -483,7 +483,7 @@ void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) {
ExceptionInfo &e = g_exceptionInfo; ExceptionInfo &e = g_exceptionInfo;
e = {}; e = {};
e.type = ExceptionType::BAD_EXEC_ADDR; e.type = ExceptionType::BAD_EXEC_ADDR;
e.info = ""; e.info.clear();
e.exec_type = type; e.exec_type = type;
e.address = address; e.address = address;
e.pc = pc; e.pc = pc;
@ -498,7 +498,7 @@ void Core_Break(u32 pc) {
ExceptionInfo &e = g_exceptionInfo; ExceptionInfo &e = g_exceptionInfo;
e = {}; e = {};
e.type = ExceptionType::BREAK; e.type = ExceptionType::BREAK;
e.info = ""; e.info.clear();
e.pc = pc; e.pc = pc;
if (!g_Config.bIgnoreBadMemAccess) { if (!g_Config.bIgnoreBadMemAccess) {

View file

@ -316,7 +316,7 @@ void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLin
dest.params = "Disassembly failure"; dest.params = "Disassembly failure";
} else { } else {
dest.name = "-"; dest.name = "-";
dest.params = ""; dest.params.clear();
} }
} }
@ -1003,7 +1003,7 @@ void DisassemblyData::createLines()
lines[currentLineStart] = entry; lines[currentLineStart] = entry;
lineAddresses.push_back(currentLineStart); lineAddresses.push_back(currentLineStart);
currentLine = ""; currentLine.clear();
currentLineStart = pos-1; currentLineStart = pos-1;
inString = false; inString = false;
} }
@ -1028,7 +1028,7 @@ void DisassemblyData::createLines()
lines[currentLineStart] = entry; lines[currentLineStart] = entry;
lineAddresses.push_back(currentLineStart); lineAddresses.push_back(currentLineStart);
currentLine = ""; currentLine.clear();
currentLineStart = pos-1; currentLineStart = pos-1;
inString = false; inString = false;
} }
@ -1099,7 +1099,7 @@ void DisassemblyData::createLines()
lines[currentLineStart] = entry; lines[currentLineStart] = entry;
lineAddresses.push_back(currentLineStart); lineAddresses.push_back(currentLineStart);
currentLine = ""; currentLine.clear();
currentLineStart = currentPos; currentLineStart = currentPos;
} }

View file

@ -262,7 +262,7 @@ bool DebuggerRequest::ParamString(const char *name, std::string *out, DebuggerPa
return true; return true;
} else if (tag == JSON_NULL) { } else if (tag == JSON_NULL) {
if (required) { if (required) {
*out = ""; (*out).clear();
} }
return true; return true;
} else if (tag == JSON_NUMBER) { } else if (tag == JSON_NUMBER) {

View file

@ -258,7 +258,7 @@ std::string SavedataParam::GetSaveFilePath(const SceUtilitySavedataParam *param,
inline static std::string FixedToString(const char *str, size_t n) inline static std::string FixedToString(const char *str, size_t n)
{ {
if (!str) { if (!str) {
return std::string(""); return std::string();
} else { } else {
return std::string(str, strnlen(str, n)); return std::string(str, strnlen(str, n));
} }

View file

@ -148,7 +148,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
if (!blockDevice->ReadBlock(16, (u8*)&desc)) if (!blockDevice->ReadBlock(16, (u8*)&desc))
blockDevice->NotifyReadError(); blockDevice->NotifyReadError();
entireISO.name = ""; entireISO.name.clear();
entireISO.isDirectory = false; entireISO.isDirectory = false;
entireISO.startingPosition = 0; entireISO.startingPosition = 0;
entireISO.size = _blockDevice->GetNumBlocks(); entireISO.size = _blockDevice->GetNumBlocks();

View file

@ -81,7 +81,6 @@ void VirtualDiscFileSystem::LoadFileListIndex() {
return; return;
} }
std::string buf;
static const int MAX_LINE_SIZE = 2048; static const int MAX_LINE_SIZE = 2048;
char linebuf[MAX_LINE_SIZE]{}; char linebuf[MAX_LINE_SIZE]{};
while (fgets(linebuf, MAX_LINE_SIZE, f)) { while (fgets(linebuf, MAX_LINE_SIZE, f)) {

View file

@ -60,7 +60,7 @@ FileLoader *ConstructFileLoader(const Path &filename) {
// TODO : improve, look in the file more // TODO : improve, look in the file more
IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) { IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) {
*errorString = ""; (*errorString).clear();
if (fileLoader == nullptr) { if (fileLoader == nullptr) {
*errorString = "Invalid fileLoader"; *errorString = "Invalid fileLoader";
return IdentifiedFileType::ERROR_IDENTIFYING; return IdentifiedFileType::ERROR_IDENTIFYING;

View file

@ -79,7 +79,7 @@ bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address)
g_symbolMap->GetLabels(args.labels); g_symbolMap->GetLabels(args.labels);
} }
errorText = L""; errorText.clear();
if (!runArmips(args)) if (!runArmips(args))
{ {
for (size_t i = 0; i < errors.size(); i++) for (size_t i = 0; i < errors.size(); i++)

View file

@ -426,7 +426,7 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) {
if (g_CoreParameter.graphicsContext == nullptr) { if (g_CoreParameter.graphicsContext == nullptr) {
g_CoreParameter.graphicsContext = temp; g_CoreParameter.graphicsContext = temp;
} }
g_CoreParameter.errorString = ""; g_CoreParameter.errorString.clear();
pspIsIniting = true; pspIsIniting = true;
PSP_SetLoading("Loading game..."); PSP_SetLoading("Loading game...");

View file

@ -674,7 +674,7 @@ bool GameManager::InstallRawISO(const Path &file, const std::string &originalNam
void GameManager::ResetInstallError() { void GameManager::ResetInstallError() {
if (!installInProgress_) { if (!installInProgress_) {
installError_ = ""; installError_.clear();
} }
} }

View file

@ -297,7 +297,7 @@ static void ForwardDebuggerRequest(const http::Request &request) {
// Check if this is a websocket request... // Check if this is a websocket request...
std::string upgrade; std::string upgrade;
if (!request.GetHeader("upgrade", &upgrade)) { if (!request.GetHeader("upgrade", &upgrade)) {
upgrade = ""; upgrade.clear();
} }
// Yes - proceed with the socket. // Yes - proceed with the socket.

View file

@ -55,7 +55,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
off.name = "Off"; off.name = "Off";
off.section = "Off"; off.section = "Off";
for (size_t i = 0; i < ARRAY_SIZE(off.settings); ++i) { 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].value = 0.0f;
off.settings[i].minValue = -1.0f; off.settings[i].minValue = -1.0f;
off.settings[i].maxValue = 1.0f; off.settings[i].maxValue = 1.0f;
@ -174,7 +174,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
section.Get("UsePreviousFrame", &info.usePreviousFrame, false); section.Get("UsePreviousFrame", &info.usePreviousFrame, false);
if (info.parent == "Off") if (info.parent == "Off")
info.parent = ""; info.parent.clear();
for (size_t i = 0; i < ARRAY_SIZE(info.settings); ++i) { for (size_t i = 0; i < ARRAY_SIZE(info.settings); ++i) {
auto &setting = info.settings[i]; auto &setting = info.settings[i];

View file

@ -867,8 +867,6 @@ void TextureCacheCommon::NotifyFramebuffer(VirtualFramebuffer *framebuffer, Fram
// Try to match the new framebuffer to existing textures. // Try to match the new framebuffer to existing textures.
// Backwards from the "usual" texturing case so can't share a utility function. // Backwards from the "usual" texturing case so can't share a utility function.
std::vector<AttachCandidate> candidates;
u64 cacheKey = (u64)fb_addr << 32; u64 cacheKey = (u64)fb_addr << 32;
// If it has a clut, those are the low 32 bits, so it'll be inside this range. // 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. // Also, if it's a subsample of the buffer, it'll also be within the FBO.

View file

@ -199,7 +199,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams &params) {
WARN_LOG(COMMON, "CWCHEAT: Incorrect ID(%s) - can't import cheats.", gameID_.c_str()); WARN_LOG(COMMON, "CWCHEAT: Incorrect ID(%s) - can't import cheats.", gameID_.c_str());
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
std::string line;
std::vector<std::string> title; std::vector<std::string> title;
std::vector<std::string> newList; std::vector<std::string> newList;

View file

@ -1049,7 +1049,7 @@ void EmuScreen::update() {
errLoadingFile.append(err->T(errorMessage_.c_str())); errLoadingFile.append(err->T(errorMessage_.c_str()));
screenManager()->push(new PromptScreen(errLoadingFile, "OK", "")); screenManager()->push(new PromptScreen(errLoadingFile, "OK", ""));
errorMessage_ = ""; errorMessage_.clear();
quit_ = true; quit_ = true;
return; return;
} }

View file

@ -1488,7 +1488,7 @@ void GameSettingsScreen::TriggerRestart(const char *why) {
std::string param = "--gamesettings"; std::string param = "--gamesettings";
if (editThenRestore_) { if (editThenRestore_) {
// We won't pass the gameID, so don't resume back into settings. // We won't pass the gameID, so don't resume back into settings.
param = ""; param.clear();
} else if (!gamePath_.empty()) { } else if (!gamePath_.empty()) {
param += " \"" + ReplaceAll(ReplaceAll(gamePath_.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\""; param += " \"" + ReplaceAll(ReplaceAll(gamePath_.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\"";
} }

View file

@ -502,7 +502,7 @@ void StoreScreen::CreateViews() {
selectedItem->Press(); selectedItem->Press();
} else { } else {
lastSelectedName_ = ""; lastSelectedName_.clear();
} }
} }
root_->Add(content); root_->Add(content);

View file

@ -151,7 +151,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ
size_t fileSize; size_t fileSize;
uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize); uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize);
if (!buffer) { if (!buffer) {
filename_ = ""; filename_.clear();
ERROR_LOG(IO, "Failed to read file '%s'", filename.c_str()); ERROR_LOG(IO, "Failed to read file '%s'", filename.c_str());
return false; return false;
} }
@ -159,7 +159,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ
if (retval) { if (retval) {
filename_ = filename; filename_ = filename;
} else { } else {
filename_ = ""; filename_.clear();
ERROR_LOG(IO, "Failed to load texture '%s'", filename.c_str()); ERROR_LOG(IO, "Failed to load texture '%s'", filename.c_str());
} }
delete[] buffer; delete[] buffer;

View file

@ -191,7 +191,7 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd)
matchAddress = -1; matchAddress = -1;
searching = false; searching = false;
searchQuery = ""; searchQuery.clear();
windowStart = curAddress; windowStart = curAddress;
whiteBackground = false; whiteBackground = false;
displaySymbols = true; displaySymbols = true;

View file

@ -49,7 +49,7 @@ CtrlMemView::CtrlMemView(HWND _wnd)
curAddress = 0; curAddress = 0;
debugger = 0; debugger = 0;
searchQuery = ""; searchQuery.clear();
matchAddress = -1; matchAddress = -1;
searching = false; searching = false;

View file

@ -49,12 +49,12 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, con
if (defaultValue.size() < 255) if (defaultValue.size() < 255)
textBoxContents = ConvertUTF8ToWString(defaultValue); textBoxContents = ConvertUTF8ToWString(defaultValue);
else else
textBoxContents = L""; textBoxContents.clear();
if (title != NULL) if (title != NULL)
windowTitle = title; windowTitle = title;
else else
windowTitle = L""; windowTitle.clear();
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) { if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
outvalue = ConvertWStringToUTF8(out); outvalue = ConvertWStringToUTF8(out);

View file

@ -911,7 +911,7 @@ namespace MainWindow {
if (lastSlash) { if (lastSlash) {
fn = lastSlash + 1; fn = lastSlash + 1;
} else { } else {
fn = ""; fn.clear();
} }
PSPFileInfo info = pspFileSystem.GetFileInfo(filename); PSPFileInfo info = pspFileSystem.GetFileInfo(filename);

View file

@ -211,7 +211,7 @@ std::string System_GetProperty(SystemProperty prop) {
if (wstr) if (wstr)
retval = ConvertWStringToUTF8(wstr); retval = ConvertWStringToUTF8(wstr);
else else
retval = ""; retval.clear();
GlobalUnlock(handle); GlobalUnlock(handle);
CloseClipboard(); CloseClipboard();
} }

View file

@ -107,7 +107,7 @@ bool RunTests() {
// Never report from tests. // Never report from tests.
std::string savedReportHost = g_Config.sReportHost; std::string savedReportHost = g_Config.sReportHost;
g_Config.sReportHost = ""; g_Config.sReportHost.clear();
for (size_t i = 0; i < ARRAY_SIZE(testsToRun); i++) { for (size_t i = 0; i < ARRAY_SIZE(testsToRun); i++) {
std::string testName = testsToRun[i]; std::string testName = testsToRun[i];
@ -116,7 +116,7 @@ bool RunTests() {
INFO_LOG(SYSTEM, "Preparing to execute '%s'", testName.c_str()); INFO_LOG(SYSTEM, "Preparing to execute '%s'", testName.c_str());
std::string error_string; std::string error_string;
output = ""; output.clear();
if (!PSP_Init(coreParam, &error_string)) { if (!PSP_Init(coreParam, &error_string)) {
ERROR_LOG(SYSTEM, "Failed to init unittest %s : %s", testsToRun[i], error_string.c_str()); ERROR_LOG(SYSTEM, "Failed to init unittest %s : %s", testsToRun[i], error_string.c_str());
PSP_CoreParameter().pixelWidth = pixel_xres; PSP_CoreParameter().pixelWidth = pixel_xres;

View file

@ -411,7 +411,7 @@ int main(int argc, const char* argv[])
g_Config.bFirstRun = false; g_Config.bFirstRun = false;
g_Config.bIgnoreBadMemAccess = true; g_Config.bIgnoreBadMemAccess = true;
// Never report from tests. // Never report from tests.
g_Config.sReportHost = ""; g_Config.sReportHost.clear();
g_Config.bAutoSaveSymbolMap = false; g_Config.bAutoSaveSymbolMap = false;
g_Config.iRenderingMode = FB_BUFFERED_MODE; g_Config.iRenderingMode = FB_BUFFERED_MODE;
g_Config.bHardwareTransform = true; g_Config.bHardwareTransform = true;

View file

@ -634,7 +634,7 @@ static bool TestPath() {
Path path3 = path2 / "foo/bar"; Path path3 = path2 / "foo/bar";
EXPECT_EQ_STR(path3.WithExtraExtension(".txt").ToString(), std::string("/asdf/jkl/foo/bar.txt")); 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("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:")); EXPECT_EQ_STR(Path("C:\\Yo").NavigateUp().ToString(), std::string("C:"));