From 49bd5532386811a586095e10ad7314a7f6edc8ff Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 5 Oct 2013 10:16:06 -0700 Subject: [PATCH 1/4] Avoid some shadowing warnings. --- Core/Dialog/PSPGamedataInstallDialog.cpp | 1 - Core/Dialog/PSPOskDialog.cpp | 12 ++++++------ Core/HLE/sceHttp.cpp | 4 ++-- Core/HLE/sceKernelMsgPipe.cpp | 6 +++--- Core/Reporting.cpp | 10 +++++----- GPU/GLES/Spline.cpp | 12 ++++++------ 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Core/Dialog/PSPGamedataInstallDialog.cpp b/Core/Dialog/PSPGamedataInstallDialog.cpp index 2f5b3208d7..1ade5dc3cb 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.cpp +++ b/Core/Dialog/PSPGamedataInstallDialog.cpp @@ -26,7 +26,6 @@ namespace std::vector GetPSPFileList (std::string dirpath) { std::vector FileList; auto Fileinfos = pspFileSystem.GetDirListing(dirpath); - std::string info; for (auto it = Fileinfos.begin(); it != Fileinfos.end(); ++it) { std::string info = (*it).name; diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 72c97f0b2e..eeb7271cd1 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -381,14 +381,14 @@ std::wstring PSPOskDialog::CombinationKorean(bool isInput) } } } else { - int tmp = GetIndex(kor_lcons, sw); + int tmp2 = GetIndex(kor_lcons, sw); - if(tmp == -1) { + if (tmp2 == -1) { string += inputChars[i]; if (inputChars.size() < FieldMaxLength()) { string += sw; - if(isInput == true) { + if (isInput == true) { i_value[0] = GetIndex(kor_cons, sw); if(i_value[0] != -1) @@ -400,13 +400,13 @@ std::wstring PSPOskDialog::CombinationKorean(bool isInput) isCombinated = false; } } else { - u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + tmp + 1; + u16 code = 0xAC00 + i_value[0] * 0x24C + i_value[1] * 0x1C + tmp2 + 1; string += code; - if(isInput == true) { + if (isInput == true) { i_level = 3; - i_value[2] = tmp; + i_value[2] = tmp2; } } } diff --git a/Core/HLE/sceHttp.cpp b/Core/HLE/sceHttp.cpp index c188f16c93..9b58d96bea 100644 --- a/Core/HLE/sceHttp.cpp +++ b/Core/HLE/sceHttp.cpp @@ -165,8 +165,8 @@ int sceHttpCreateRequest(int connectionID, int method, const char *path, u64 con return 0; } -int sceHttpCreateConnection(int templateID, const char *host, const char *unknown1, u32 port, int unknown2) { - ERROR_LOG(SCENET, "UNIMPL sceHttpCreateConnection(%d, %s, %s, %d, %d)", templateID, host, unknown1, port, unknown2); +int sceHttpCreateConnection(int templateID, const char *hostString, const char *unknown1, u32 port, int unknown2) { + ERROR_LOG(SCENET, "UNIMPL sceHttpCreateConnection(%d, %s, %s, %d, %d)", templateID, hostString, unknown1, port, unknown2); return 0; } diff --git a/Core/HLE/sceKernelMsgPipe.cpp b/Core/HLE/sceKernelMsgPipe.cpp index 6a75df6815..30eee3ab98 100644 --- a/Core/HLE/sceKernelMsgPipe.cpp +++ b/Core/HLE/sceKernelMsgPipe.cpp @@ -717,9 +717,9 @@ int sceKernelCreateMsgPipe(const char *name, int partition, u32 attr, u32 size, if (optionsPtr != 0) { - u32 size = Memory::Read_U32(optionsPtr); - if (size > 4) - WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateMsgPipe(%s) unsupported options parameter, size = %d", name, size); + u32 optionsSize = Memory::Read_U32(optionsPtr); + if (optionsSize > 4) + WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateMsgPipe(%s) unsupported options parameter, size = %d", name, optionsSize); } return id; diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 5f29aa68e7..19b9ed1fe9 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -76,16 +76,16 @@ namespace Reporting return g_Config.sReportHost.npos; // IPv6 literal? - std::string host = ServerHost(); - if (host[0] == '[') + std::string hostString = ServerHost(); + if (hostString[0] == '[') { - size_t length = host.find("]:"); - if (length != host.npos) + size_t length = hostString.find("]:"); + if (length != hostString.npos) ++length; return length; } else - return host.find(':'); + return hostString.find(':'); } // Returns only the hostname part (e.g. "report.ppsspp.org".) diff --git a/GPU/GLES/Spline.cpp b/GPU/GLES/Spline.cpp index ecd303e0e0..f4fa5238be 100644 --- a/GPU/GLES/Spline.cpp +++ b/GPU/GLES/Spline.cpp @@ -83,15 +83,15 @@ u32 TransformDrawEngine::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inP // Skinning Vec3f psum(0,0,0); Vec3f nsum(0,0,0); - for (int i = 0; i < numBoneWeights; i++) { - if (weights[i] != 0.0f) { - Vec3ByMatrix43(bpos, pos, gstate.boneMatrix+i*12); + for (int w = 0; w < numBoneWeights; w++) { + if (weights[w] != 0.0f) { + Vec3ByMatrix43(bpos, pos, gstate.boneMatrix+w*12); Vec3f tpos(bpos); - psum += tpos * weights[i]; + psum += tpos * weights[w]; - Norm3ByMatrix43(bnrm, nrm, gstate.boneMatrix+i*12); + Norm3ByMatrix43(bnrm, nrm, gstate.boneMatrix+w*12); Vec3f tnorm(bnrm); - nsum += tnorm * weights[i]; + nsum += tnorm * weights[w]; } } sv.pos = psum; From 1b1a8cef02c784ecef28ad6a274cc74cc3bd8294 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 5 Oct 2013 10:16:25 -0700 Subject: [PATCH 2/4] Fix a potential null pointer. --- Core/HLE/sceKernelMsgPipe.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Core/HLE/sceKernelMsgPipe.cpp b/Core/HLE/sceKernelMsgPipe.cpp index 30eee3ab98..10caba282e 100644 --- a/Core/HLE/sceKernelMsgPipe.cpp +++ b/Core/HLE/sceKernelMsgPipe.cpp @@ -610,6 +610,12 @@ void __KernelMsgPipeEndCallback(SceUID threadID, SceUID prevCallbackId) SceUID uid = __KernelGetWaitID(threadID, WAITTYPE_MSGPIPE, error); MsgPipe *ko = uid == 0 ? NULL : kernelObjects.Get(uid, error); + if (ko == NULL) + { + ERROR_LOG_REPORT(SCEKERNEL, "__KernelMsgPipeEndCallback: Invalid object"); + return; + } + switch (waitValue) { case MSGPIPE_WAIT_VALUE_SEND: From 093255a89534f3318aa7713124b59d9a6ca4e762 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 5 Oct 2013 10:17:46 -0700 Subject: [PATCH 3/4] Avoid an unlikely buffer overflow. --- Core/System.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/System.cpp b/Core/System.cpp index 1e84d483a2..ca39a6b6a1 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -346,7 +346,7 @@ void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { char memstickpath_buf[_MAX_PATH]; char flash0path_buf[_MAX_PATH]; - GetModuleFileName(NULL, path_buffer, sizeof(path_buffer)); + GetModuleFileName(NULL, path_buffer, ARRAY_SIZE(path_buffer)); std::string path = ConvertWStringToUTF8(path_buffer); From 3a1b6fb26989e20d3f23e49a1f709412662cdbbf Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 5 Oct 2013 10:31:57 -0700 Subject: [PATCH 4/4] Fix some sign comparison warnings. --- Core/HLE/__sceAudio.cpp | 2 +- Core/HLE/sceAtrac.cpp | 4 ++-- Core/HLE/sceGe.cpp | 2 +- Core/MIPS/ARM/ArmCompBranch.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 10f05c7519..3f1774ebfc 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -290,7 +290,7 @@ void __AudioUpdate() { continue; } - if (hwBlockSize * 2 > chans[i].sampleQueue.size()) { + if (hwBlockSize * 2 > (int)chans[i].sampleQueue.size()) { ERROR_LOG(SCEAUDIO, "Channel %i buffer underrun at %i of %i", i, (int)chans[i].sampleQueue.size() / 2, hwBlockSize); } diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 493e312f1b..097a7a568b 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -728,7 +728,7 @@ u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishF u32 finish = 0; int remains = 0; int ret = _AtracDecodeData(atracID, Memory::GetPointer(outAddr), &numSamples, &finish, &remains); - if (ret != ATRAC_ERROR_BAD_ATRACID) { + if (ret != (int)ATRAC_ERROR_BAD_ATRACID) { Memory::Write_U32(numSamples, numSamplesAddr); Memory::Write_U32(finish, finishFlagAddr); Memory::Write_U32(remains, remainAddr); @@ -1230,7 +1230,7 @@ u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize) atrac->first.addr = buffer; atrac->first.size = bufferSize; int ret = atrac->Analyze(); - if (ret == 0 && atrac->codecType != atracIDTypes[atracID]) { + if (ret == 0 && (int)atrac->codecType != atracIDTypes[atracID]) { ERROR_LOG(ME, "sceAtracSetData(%i, %08x, %08x): atracID uses different codec type than data", atracID, buffer, bufferSize); ret = ATRAC_ERROR_WRONG_CODECTYPE; } diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index a835c5d8d3..773b9ba78b 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -583,7 +583,7 @@ int sceGeGetMtx(int type, u32 matrixPtr) { u32 sceGeGetCmd(int cmd) { INFO_LOG(SCEGE, "sceGeGetCmd(%i)", cmd); - if (cmd >= 0 && cmd < ARRAY_SIZE(gstate.cmdmem)) { + if (cmd >= 0 && cmd < (int)ARRAY_SIZE(gstate.cmdmem)) { return gstate.cmdmem[cmd]; // Does not mask away the high bits. } else { return SCE_KERNEL_ERROR_INVALID_INDEX; diff --git a/Core/MIPS/ARM/ArmCompBranch.cpp b/Core/MIPS/ARM/ArmCompBranch.cpp index 8f446f22ce..9bca9d8be3 100644 --- a/Core/MIPS/ARM/ArmCompBranch.cpp +++ b/Core/MIPS/ARM/ArmCompBranch.cpp @@ -284,7 +284,7 @@ void Jit::BranchVFPUFlag(MIPSOpcode op, ArmGen::CCFlags cc, bool likely) CONDITIONAL_NICE_DELAYSLOT; if (!likely && delaySlotIsNice) CompileDelaySlot(DELAYSLOT_NICE); - if (delaySlotIsBranch && (delaySlotOp & 0xFFFF) != (signed short)(op & 0xFFFF) - 1) + if (delaySlotIsBranch && (signed short)(delaySlotOp & 0xFFFF) != (signed short)(op & 0xFFFF) - 1) ERROR_LOG_REPORT(JIT, "VFPU branch in VFPU delay slot at %08x with different target", js.compilerPC); int imm3 = (op >> 18) & 7;