From e18ee42afc2dc0f05764242bfc93709bc1ce361d Mon Sep 17 00:00:00 2001 From: ty Date: Thu, 11 Mar 2021 19:48:35 -0500 Subject: [PATCH] Misc: Fix various DebugTools Codacy complaints --- pcsx2/DEV9/Win32/pcap_io_win32.cpp | 4 ++-- pcsx2/DebugTools/BiosDebugData.cpp | 2 +- pcsx2/DebugTools/DisassemblyManager.cpp | 7 ++++--- pcsx2/DebugTools/DisassemblyManager.h | 4 ++-- pcsx2/DebugTools/MipsAssembler.cpp | 3 +-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pcsx2/DEV9/Win32/pcap_io_win32.cpp b/pcsx2/DEV9/Win32/pcap_io_win32.cpp index da480f99ea..e8eb3232dc 100644 --- a/pcsx2/DEV9/Win32/pcap_io_win32.cpp +++ b/pcsx2/DEV9/Win32/pcap_io_win32.cpp @@ -91,7 +91,7 @@ bool load_pcap() len = GetDllDirectory(len, oldDllDir); if (len == 0) { - delete oldDllDir; + delete[] oldDllDir; return false; } } @@ -104,7 +104,7 @@ bool load_pcap() //Reset DllDirectory SetDllDirectory(oldDllDir); - delete oldDllDir; + delete[] oldDllDir; //Did we succeed? if (hpcap == nullptr) diff --git a/pcsx2/DebugTools/BiosDebugData.cpp b/pcsx2/DebugTools/BiosDebugData.cpp index 75a536147b..b1cf87a713 100644 --- a/pcsx2/DebugTools/BiosDebugData.cpp +++ b/pcsx2/DebugTools/BiosDebugData.cpp @@ -29,7 +29,7 @@ std::vector getEEThreads() { EEThread thread; - EEInternalThread* internal = (EEInternalThread*) PSM(start+tid*sizeof(EEInternalThread)); + EEInternalThread* internal = static_cast(PSM(start + tid * sizeof(EEInternalThread))); if (internal->status != THS_BAD) { thread.tid = tid; diff --git a/pcsx2/DebugTools/DisassemblyManager.cpp b/pcsx2/DebugTools/DisassemblyManager.cpp index d20f55a0f7..ea310b7de5 100644 --- a/pcsx2/DebugTools/DisassemblyManager.cpp +++ b/pcsx2/DebugTools/DisassemblyManager.cpp @@ -457,6 +457,7 @@ void DisassemblyFunction::generateBranchLines() if (opInfo.isBranch && !opInfo.isBranchToRegister && !opInfo.isLinkedBranch && inFunction) { BranchLine line; + line.laneIndex = 0; if (opInfo.branchTarget < funcPos) { line.first = opInfo.branchTarget; @@ -471,7 +472,7 @@ void DisassemblyFunction::generateBranchLines() lines.push_back(line); } } - + std::sort(lines.begin(),lines.end()); for (size_t i = 0; i < lines.size(); i++) { @@ -748,7 +749,7 @@ void DisassemblyMacro::setMacroLi(u32 _immediate, u8 _rt) numOpcodes = 2; } -void DisassemblyMacro::setMacroMemory(std::string _name, u32 _immediate, u8 _rt, int _dataSize) +void DisassemblyMacro::setMacroMemory(const std::string& _name, u32 _immediate, u8 _rt, int _dataSize) { type = MACRO_MEMORYIMM; name = _name; @@ -1021,7 +1022,7 @@ void DisassemblyData::createLines() } -DisassemblyComment::DisassemblyComment(DebugInterface* _cpu, u32 _address, u32 _size, std::string _name, std::string _param) +DisassemblyComment::DisassemblyComment(DebugInterface* _cpu, u32 _address, u32 _size, const std::string& _name, const std::string& _param) : cpu(_cpu), address(_address), size(_size), name(_name), param(_param) { diff --git a/pcsx2/DebugTools/DisassemblyManager.h b/pcsx2/DebugTools/DisassemblyManager.h index bd5165c5ce..198ff9d2c9 100644 --- a/pcsx2/DebugTools/DisassemblyManager.h +++ b/pcsx2/DebugTools/DisassemblyManager.h @@ -115,7 +115,7 @@ public: virtual ~DisassemblyMacro() { }; void setMacroLi(u32 _immediate, u8 _rt); - void setMacroMemory(std::string _name, u32 _immediate, u8 _rt, int _dataSize); + void setMacroMemory(const std::string& _name, u32 _immediate, u8 _rt, int _dataSize); virtual void recheck() { }; virtual int getNumLines() { return 1; }; @@ -171,7 +171,7 @@ private: class DisassemblyComment: public DisassemblyEntry { public: - DisassemblyComment(DebugInterface* _cpu, u32 _address, u32 _size, std::string name, std::string param); + DisassemblyComment(DebugInterface* _cpu, u32 _address, u32 _size,const std::string& name, const std::string& param); virtual ~DisassemblyComment() { }; virtual void recheck() { }; diff --git a/pcsx2/DebugTools/MipsAssembler.cpp b/pcsx2/DebugTools/MipsAssembler.cpp index c83ef2a323..a10c84c877 100644 --- a/pcsx2/DebugTools/MipsAssembler.cpp +++ b/pcsx2/DebugTools/MipsAssembler.cpp @@ -462,8 +462,6 @@ bool CMipsInstruction::parseOpcode(const tMipsOpcode& SourceOpcode, const char* bool CMipsInstruction::LoadEncoding(const tMipsOpcode& SourceOpcode, const char* Line) { - int RetLen; - immediateType = MIPS_NOIMMEDIATE; registers.reset(); @@ -481,6 +479,7 @@ bool CMipsInstruction::LoadEncoding(const tMipsOpcode& SourceOpcode, const char* if (!(*SourceEncoding == 0 && *Line == 0)) { + int RetLen; while (*SourceEncoding != 0) { while (*Line == ' ' || *Line == '\t') Line++;