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);
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;
}

View File

@ -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_);

View File

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

View File

@ -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]{};

View File

@ -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;

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,
// 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();
}
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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) {

View File

@ -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));
}

View File

@ -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();

View File

@ -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)) {

View File

@ -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;

View File

@ -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++)

View File

@ -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...");

View File

@ -674,7 +674,7 @@ bool GameManager::InstallRawISO(const Path &file, const std::string &originalNam
void GameManager::ResetInstallError() {
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...
std::string upgrade;
if (!request.GetHeader("upgrade", &upgrade)) {
upgrade = "";
upgrade.clear();
}
// 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.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<Path> &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];

View File

@ -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<AttachCandidate> 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.

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());
return UI::EVENT_DONE;
}
std::string line;
std::vector<std::string> title;
std::vector<std::string> newList;

View File

@ -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;
}

View File

@ -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(), "\\", "\\\\"), "\"", "\\\"") + "\"";
}

View File

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

View File

@ -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;

View File

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

View File

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

View File

@ -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);

View File

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

View File

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

View File

@ -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;

View File

@ -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;

View File

@ -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:"));