From 2b22bfed1c5fcea8ea188dfe4d0c441b70c99565 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 18 Mar 2016 00:48:24 -0700 Subject: [PATCH] Cleaned up /analyze warnings with VS 2015 Update 2 --- .gitignore | 1 + DDSView/ddsview.cpp | 12 ++++++------ DirectXTex/DirectXTexConvert.cpp | 6 +++--- DirectXTex/DirectXTexWIC.cpp | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index dedd8d8..d913611 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ *.tlog *.lastbuildstate *.ilk +*.VC.db Bin /ipch Debug diff --git a/DDSView/ddsview.cpp b/DDSView/ddsview.cpp index e8df425..2229879 100644 --- a/DDSView/ddsview.cpp +++ b/DDSView/ddsview.cpp @@ -110,7 +110,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, HRESULT hr = GetMetadataFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, mdata ); if ( FAILED(hr) ) { - WCHAR buff[2048]; + WCHAR buff[2048] = { 0 }; swprintf_s( buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr ); MessageBox( NULL, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; @@ -131,7 +131,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, { if ( mdata.arraySize > 1 ) { - WCHAR buff[2048]; + WCHAR buff[2048] = { 0 }; swprintf_s( buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %Iu", lpCmdLine, mdata.arraySize ); MessageBox( NULL, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; @@ -154,7 +154,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, case DXGI_FORMAT_BC7_UNORM_SRGB: if ( g_featureLevel < D3D_FEATURE_LEVEL_11_0 ) { - WCHAR buff[2048]; + WCHAR buff[2048] = { 0 }; swprintf_s( buff, L"BC6H/BC7 requires DirectX 11 hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel ); MessageBox( NULL, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; @@ -167,7 +167,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, hr = g_pd3dDevice->CheckFormatSupport ( mdata.format, &flags ); if ( FAILED(hr) || !(flags & (D3D11_FORMAT_SUPPORT_TEXTURE1D|D3D11_FORMAT_SUPPORT_TEXTURE2D|D3D11_FORMAT_SUPPORT_TEXTURE3D)) ) { - WCHAR buff[2048]; + WCHAR buff[2048] = { 0 }; swprintf_s( buff, L"Format not supported by DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", lpCmdLine, mdata.format, g_featureLevel, hr ); MessageBox( NULL, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; @@ -180,7 +180,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, hr = LoadFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, &mdata, image ); if ( FAILED(hr) ) { - WCHAR buff[2048]; + WCHAR buff[2048] = { 0 }; swprintf_s( buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr ); MessageBox( NULL, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; @@ -192,7 +192,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, hr = CreateShaderResourceView( g_pd3dDevice, image.GetImages(), image.GetImageCount(), mdata, &g_pSRV ); if ( FAILED(hr) ) { - WCHAR buff[2048]; + WCHAR buff[2048] = { 0 }; swprintf_s( buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", lpCmdLine, hr ); MessageBox( NULL, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); return 0; diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index a406b15..e5d155f 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -3010,7 +3010,7 @@ DWORD _GetConvertFlags( DXGI_FORMAT format ) ConvertData key = { format, 0 }; const ConvertData* in = (const ConvertData*) bsearch_s( &key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), - _ConvertCompare, 0 ); + _ConvertCompare, nullptr ); return (in) ? in->flags : 0; } @@ -3038,10 +3038,10 @@ void _ConvertScanline( XMVECTOR* pBuffer, size_t count, DXGI_FORMAT outFormat, D // Determine conversion details about source and dest formats ConvertData key = { inFormat, 0 }; const ConvertData* in = (const ConvertData*) bsearch_s( &key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), - _ConvertCompare, 0 ); + _ConvertCompare, nullptr ); key.format = outFormat; const ConvertData* out = (const ConvertData*) bsearch_s( &key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), - _ConvertCompare, 0 ); + _ConvertCompare, nullptr ); if ( !in || !out ) { assert(false); diff --git a/DirectXTex/DirectXTexWIC.cpp b/DirectXTex/DirectXTexWIC.cpp index f51784e..bfbd94a 100644 --- a/DirectXTex/DirectXTexWIC.cpp +++ b/DirectXTex/DirectXTexWIC.cpp @@ -58,7 +58,7 @@ using Microsoft::WRL::ComPtr; #else - #pragma prefast(suppress:28196, "a simple wrapper around an existing annotated function" ); + #pragma prefast(suppress:6387 28196, "a simple wrapper around an existing annotated function" ); static inline HRESULT CreateMemoryStream( _Outptr_ IStream** stream ) { return CreateStreamOnHGlobal( 0, TRUE, stream );