Merge pull request #1272 from PatrickvL/code_analysis

Fixed a few code analysis warnings (mainly variable redeclarations)
This commit is contained in:
RadWolfie 2018-06-09 14:44:39 -05:00 committed by GitHub
commit d03151cb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 29 deletions

View File

@ -3335,17 +3335,11 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetViewport)
XB_trampoline(VOID, WINAPI, D3DDevice_SetViewport, (CONST X_D3DVIEWPORT8 *));
XB_D3DDevice_SetViewport(pViewport);
#endif
// Get current Xbox render target dimensions
DWORD XboxRenderTarget_Width = GetPixelContainerWidth(g_pXboxRenderTarget);
DWORD XboxRenderTarget_Height = GetPixelContainerHeigth(g_pXboxRenderTarget);
// Get current host render target dimensions
DWORD HostRenderTarget_Width;
DWORD HostRenderTarget_Height;
if (GetHostRenderTargetDimensions(&HostRenderTarget_Width, &HostRenderTarget_Height)) {
// Scale Xbox to host dimensions (avoiding hard-coding 640 x 480)
HostViewPort.X = ScaleDWORD(pViewport->X, XboxRenderTarget_Width, HostRenderTarget_Width);
HostViewPort.Y = ScaleDWORD(pViewport->Y, XboxRenderTarget_Height, HostRenderTarget_Height);
@ -7366,8 +7360,8 @@ void XTL::CxbxDrawIndexed(CxbxDrawContext &DrawContext)
// Close line-loops using a final single line, drawn from the end to the start vertex
LOG_TEST_CASE("X_D3DPT_LINELOOP");
// Read the end and start index from the supplied index data
INDEX16 LowIndex = DrawContext.pIndexData[0];
INDEX16 HighIndex = DrawContext.pIndexData[DrawContext.dwHostPrimitiveCount];
LowIndex = DrawContext.pIndexData[0];
HighIndex = DrawContext.pIndexData[DrawContext.dwHostPrimitiveCount];
// If needed, swap so highest index is higher than lowest (duh)
if (HighIndex < LowIndex) {
HighIndex ^= LowIndex;
@ -7846,8 +7840,8 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_DrawIndexedVerticesUP)
// Close line-loops using a final single line, drawn from the end to the start vertex
LOG_TEST_CASE("X_D3DPT_LINELOOP"); // TODO : Which titles reach this case?
// Read the end and start index from the supplied index data
INDEX16 LowIndex = ((INDEX16*)pIndexData)[0];
INDEX16 HighIndex = ((INDEX16*)pIndexData)[DrawContext.dwHostPrimitiveCount];
LowIndex = ((INDEX16*)pIndexData)[0];
HighIndex = ((INDEX16*)pIndexData)[DrawContext.dwHostPrimitiveCount];
// If needed, swap so highest index is higher than lowest (duh)
if (HighIndex < LowIndex) {
HighIndex ^= LowIndex;

View File

@ -6181,8 +6181,8 @@ inline BOOL OptimizeOperation
}
} else if(strcmp(szOp2, "cnd")==0) {
#ifdef REVEL8N_PIXEL_SHADER_CHANGES
int iOffset = 0;
int i = 0;
iOffset = 0;
i = 0;
for (i = 0; i < 2; ++i)
{
if (strcmp(szOps[i], "mul")==0)
@ -6276,17 +6276,18 @@ inline void CorrectConstToReg(char *szConst, int *pPSC0, int *pPSC1)
// Add this const to the beginning of the psh
char str[100];
char *szNewCodeBuffer = (char *)malloc((strlen(pCodeBuffer)+70)*sizeof(char));
strncpy(szNewCodeBuffer, pCodeBuffer, 7);
szNewCodeBuffer[7]=0x00;
sprintf(str, "def c%d, %ff, %ff, %ff, %ff\n", i,
fConst,fConst,fConst,fConst);
iPreRunLen+=strlen(str);
strcat(szNewCodeBuffer, str);
strcat(szNewCodeBuffer, &pCodeBuffer[7]);
strcpy(pCodeBuffer, szNewCodeBuffer);
free(szNewCodeBuffer);
if (szNewCodeBuffer) {
strncpy(szNewCodeBuffer, pCodeBuffer, 7);
szNewCodeBuffer[7] = 0x00;
sprintf(str, "def c%d, %ff, %ff, %ff, %ff\n", i,
fConst, fConst, fConst, fConst);
iPreRunLen += strlen(str);
strcat(szNewCodeBuffer, str);
strcat(szNewCodeBuffer, &pCodeBuffer[7]);
strcpy(pCodeBuffer, szNewCodeBuffer);
free(szNewCodeBuffer);
}
iConstCount++;
printf("added: %s\n", str);

View File

@ -874,9 +874,9 @@ static void VshWriteShader(VSH_XBOX_SHADER *pShader,
VshWriteOutputMask(pIntermediate->Output.Mask, pDisassembly, &DisassemblyPos);
}
// Print the parameters
for (int i = 0; i < 3; i++)
for (int p = 0; p < 3; p++)
{
VSH_IMD_PARAMETER *pParameter = &pIntermediate->Parameters[i];
VSH_IMD_PARAMETER *pParameter = &pIntermediate->Parameters[p];
if(pParameter->Active)
{
VshWriteParameter(pParameter, pDisassembly, &DisassemblyPos);
@ -2430,7 +2430,7 @@ extern HRESULT XTL::EmuRecompileVshFunction
if(!pShader)
{
EmuWarning("Couldn't allocate memory for vertex shader conversion buffer");
hRet = E_OUTOFMEMORY;
return E_OUTOFMEMORY;
}
pShader->ShaderHeader = *pShaderHeader;
switch(pShaderHeader->Version)

View File

@ -536,7 +536,7 @@ XboxDevice *CxbxDeviceByDevicePath(const std::string XboxDevicePath)
int CxbxRegisterDeviceHostPath(std::string XboxDevicePath, std::string HostDevicePath, bool IsFile)
{
int result = -1;
NTSTATUS status;
NTSTATUS status = (NTSTATUS)-1;
XboxDevice newDevice;
newDevice.XboxDevicePath = XboxDevicePath;

View File

@ -1012,7 +1012,7 @@ XBSYSAPI EXPORTNUM(206) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueueApcThread
else
{
g_DuplicateHandles[ThreadHandle] = hApcThread; // Save this thread because we'll need to de-reference it later
DbgPrintf( "DuplicateHandle returned 0x%X (ThreadId)\n", hApcThread, GetThreadId( hApcThread ) );
DbgPrintf( "DuplicateHandle returned 0x%X (ThreadId 0x%.4X)\n", hApcThread, GetThreadId( hApcThread ) );
}

View File

@ -213,12 +213,12 @@ namespace DlgVSBCFeedback
{
HWND hWndButton = GetDlgItem(hWndDlg, LOWORD(wParam));
switch (LOWORD(wParam))
// switch (LOWORD(wParam))
{
//case IDC_HOST_CANCEL:
// //EndDialog(hWndDlg, wParam);
//break;
default:
// default:
return FALSE;
}