From f5d4fe0bfe13937fa3736aa6b78974ceb6e190ad Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 3 Mar 2012 20:07:20 +0100 Subject: [PATCH] Fix some minor bugs pointed out by PVS Studio (thanks!) --- Source/Core/Common/Src/SysConf.cpp | 2 +- Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp | 2 +- Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp | 2 +- Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp | 2 +- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 2 +- Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp | 2 +- Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/Common/Src/SysConf.cpp b/Source/Core/Common/Src/SysConf.cpp index ed8a4953e5..97170e5ff1 100644 --- a/Source/Core/Common/Src/SysConf.cpp +++ b/Source/Core/Common/Src/SysConf.cpp @@ -387,7 +387,7 @@ bool SysConf::SaveToFile(const char *filename) } else if (i->type == Type_SmallArray) { - const u8 len = i->dataLength; + const u8 len = (u8)(i->dataLength); f.WriteArray(&len, 1); } diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index 144270e798..4aefb6dbdb 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -109,7 +109,7 @@ CEXIIPL::CEXIIPL() : if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHLE_BS2) { // Copy header - memcpy(m_pIPL, m_bNTSC ? iplverNTSC : iplverPAL, sizeof(m_bNTSC ? iplverNTSC : iplverPAL)); + memcpy(m_pIPL, m_bNTSC ? iplverNTSC : iplverPAL, m_bNTSC ? sizeof(iplverNTSC) : sizeof(iplverPAL)); // Load fonts LoadFileToIPL((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SJIS), 0x1aff00); diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp index 3a60a0ae11..8ca83e7208 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp @@ -1212,7 +1212,7 @@ void IRBuilder::simplifyCommutative(unsigned Opcode, InstLoc& Op1, InstLoc& Op2) } bool IRBuilder::maskedValueIsZero(InstLoc Op1, InstLoc Op2) const { - return (~ComputeKnownZeroBits(Op1) & ~ComputeKnownZeroBits(Op1)) == 0; + return (~ComputeKnownZeroBits(Op1) & ~ComputeKnownZeroBits(Op2)) == 0; } // Returns I' if I == (0 - I') diff --git a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp index f354ea4291..c3aa56acd0 100644 --- a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp @@ -299,7 +299,7 @@ u32 Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa, merged_addresses[0] = address; size_of_merged_addresses = 1; - memset(st, 0, sizeof(st)); + memset(st, 0, sizeof(*st)); // Disabled the following optimization in preference of FAST_ICACHE //UGeckoInstruction previnst = Memory::Read_Opcode_JIT_LC(address - 4); diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index fe5827de05..3ef923dc3e 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -158,7 +158,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo } u32* ptr = &uid->values[2]; - for (int i = 0; i < bpmem.genMode.numtevstages+1; ++i) + for (unsigned int i = 0; i < bpmem.genMode.numtevstages+1; ++i) { StageHash(i, ptr); ptr += 4; // max: ptr = &uid->values[66] diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp index 81a4cf96a6..8ee8081b2c 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp @@ -595,7 +595,7 @@ void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture, // only upload the data to VRAM if it changed if (stsq_observer || - memcmp(rDest, &tex_sub_quad_data.rdest, sizeof(rDest)) != 0 || + memcmp(rDest, &tex_sub_quad_data.rdest, sizeof(*rDest)) != 0 || tex_sub_quad_data.u1 != u1 || tex_sub_quad_data.v1 != v1 || tex_sub_quad_data.u2 != u2 || tex_sub_quad_data.v2 != v2 || tex_sub_quad_data.G != G) { diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 3a4b5d0699..9510ad444c 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -383,7 +383,7 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture, float v2=((float)rSource->bottom) * sh; float g = 1.0f/Gamma; - struct Q2DVertex { float x,y,z,rhw,u,v,w,h,G; } coords[4] = { + const struct Q2DVertex { float x,y,z,rhw,u,v,w,h,G; } coords[4] = { {-1.0f - dw,-1.0f + dh, 0.0f,1.0f, u1, v2, sw, sh, g}, {-1.0f - dw, 1.0f + dh, 0.0f,1.0f, u1, v1, sw, sh, g}, { 1.0f - dw,-1.0f + dh, 0.0f,1.0f, u2, v2, sw, sh, g},