From b2ff6504b93a35375387fb01470bd20c0b0cec73 Mon Sep 17 00:00:00 2001 From: Jamie Madill Date: Wed, 15 Mar 2017 16:17:46 -0400 Subject: build: Fix potentially uninitialized VS2015 warning This fixes the a few occurences in demos, the loader and a test. It also adds the warning to the always-on list so it will prevent future regressions. Fixes #1587. Change-Id: I26f69e977b57749a3ab4ddb548ada95384131edc --- CMakeLists.txt | 3 +++ demos/cube.c | 3 +++ demos/cube.cpp | 3 +++ demos/smoke/ShellWin32.cpp | 2 +- loader/loader.c | 4 ++-- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a982fefe..b53696fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,9 @@ if(WIN32) add_compile_options("$<$:/GR->") # Warn about nested declarations add_compile_options("$<$:/w34456>") + # Warn about potentially uninitialized variables + add_compile_options("$<$:/w34701>") + add_compile_options("$<$:/w34703>") endif() if(NOT WIN32) diff --git a/demos/cube.c b/demos/cube.c index 8985c971..b1706a96 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -3530,6 +3530,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int argc; char **argv; + // Ensure wParam is initialized. + msg.wParam = 0; + // Use the CommandLine functions to get the command line arguments. // Unfortunately, Microsoft outputs // this information as wide characters for Unicode, and we simply want the diff --git a/demos/cube.cpp b/demos/cube.cpp index 011c456f..082ab4d0 100644 --- a/demos/cube.cpp +++ b/demos/cube.cpp @@ -2678,6 +2678,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int argc; char **argv; + // Ensure wParam is initialized. + msg.wParam = 0; + // Use the CommandLine functions to get the command line arguments. // Unfortunately, Microsoft outputs // this information as wide characters for Unicode, and we simply want the diff --git a/demos/smoke/ShellWin32.cpp b/demos/smoke/ShellWin32.cpp index f5b68259..69ef38b4 100644 --- a/demos/smoke/ShellWin32.cpp +++ b/demos/smoke/ShellWin32.cpp @@ -90,7 +90,7 @@ void ShellWin32::create_window() { PFN_vkGetInstanceProcAddr ShellWin32::load_vk() { const char filename[] = "vulkan-1.dll"; HMODULE mod; - PFN_vkGetInstanceProcAddr get_proc; + PFN_vkGetInstanceProcAddr get_proc = NULL; mod = LoadLibrary(filename); if (mod) { diff --git a/loader/loader.c b/loader/loader.c index 9a99759e..9b794b63 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -3976,8 +3976,8 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p VkDeviceCreateInfo loader_create_info; VkResult res; - PFN_vkGetDeviceProcAddr fpGDPA, nextGDPA = loader_gpa_device_internal; - PFN_vkGetInstanceProcAddr fpGIPA, nextGIPA = loader_gpa_instance_internal; + PFN_vkGetDeviceProcAddr fpGDPA = NULL, nextGDPA = loader_gpa_device_internal; + PFN_vkGetInstanceProcAddr fpGIPA = NULL, nextGIPA = loader_gpa_instance_internal; memcpy(&loader_create_info, pCreateInfo, sizeof(VkDeviceCreateInfo)); -- cgit v1.2.3