misc: Changes to fix warnings in Windows / VC++ build
authorTony Barbour <tony@LunarG.com>
Wed, 22 Apr 2015 17:36:22 +0000 (11:36 -0600)
committerTony Barbour <tony@LunarG.com>
Wed, 22 Apr 2015 18:47:54 +0000 (12:47 -0600)
demos/cube.c
demos/tri.c
layers/basic.cpp
layers/draw_state.cpp
layers/mem_tracker.cpp
layers/multi.cpp
layers/param_checker.cpp
libs/xcb_nvidia/xcb_nvidia.cpp
loader/loader.c
vk-generate.py
vk-layer-generate.py

index 6429000..3aa2128 100644 (file)
@@ -696,7 +696,8 @@ bool loadTexture(const char *filename, uint8_t *rgba_data,
 {
   //header for testing if it is a png
   png_byte header[8];
-  int is_png, bit_depth, color_type,rowbytes, retval;
+  int is_png, bit_depth, color_type, rowbytes;
+  size_t retval;
   png_uint_32 i, twidth, theight;
   png_structp  png_ptr;
   png_infop info_ptr, end_info;
@@ -1237,7 +1238,7 @@ static VkShader demo_prepare_shader(struct demo *demo,
     err = vkCreateShader(demo->device, &createInfo, &shader);
     if (err) {
         free((void *) createInfo.pCode);
-        return NULL;
+        return (VkShader) VK_NULL_HANDLE;
     }
 #endif
 
@@ -1247,7 +1248,7 @@ static VkShader demo_prepare_shader(struct demo *demo,
 char *demo_read_spv(const char *filename, size_t *psize)
 {
     long int size;
-    int U_ASSERT_ONLY retval;
+    size_t U_ASSERT_ONLY retval;
     void *shader_code;
 
     FILE *fp = fopen(filename, "rb");
@@ -1621,8 +1622,6 @@ LRESULT CALLBACK WndProc(HWND hWnd,
                          WPARAM wParam,
                          LPARAM lParam)
 {
-    PAINTSTRUCT paint_struct;
-    HDC hDC; // Device context
     char tmp_str[] = "Test Vulkan Cube Program"; 
 
     switch(uMsg)
@@ -2059,7 +2058,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
     /* main message loop*/
     while(!done)
     {
-        PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE);
+        PeekMessage(&msg,0,0,0,PM_REMOVE);
         if (msg.message == WM_QUIT) //check for a quit message
         {
             done = true; //if found, quit app
@@ -2074,7 +2073,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
 
     demo_cleanup(&demo);
 
-    return msg.wParam;
+    return (int) msg.wParam;
 }
 #else  // _WIN32
 int main(int argc, char **argv)
index cf94425..0504dbe 100644 (file)
@@ -1172,8 +1172,6 @@ LRESULT CALLBACK WndProc(HWND hWnd,
                          WPARAM wParam,
                          LPARAM lParam)
 {
-    PAINTSTRUCT paint_struct;
-    HDC hDC; // Device context
     char tmp_str[] = "Test Vulkan Triangle Program"; 
 
     switch(uMsg)
@@ -1571,7 +1569,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
     /* main message loop*/
     while(!done)
     {
-        PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE);
+        PeekMessage(&msg,0,0,0,PM_REMOVE);
         if (msg.message == WM_QUIT) //check for a quit message
         {
             done = true; //if found, quit app
@@ -1586,7 +1584,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
 
     demo_cleanup(&demo);
 
-    return msg.wParam;
+    return (int) msg.wParam;
 }
 #else  // _WIN32
 int main(const int argc, const char *argv[])
index 64964f3..260f7c3 100644 (file)
@@ -78,8 +78,6 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
                                                size_t*  pDataSize,
                                                void*    pData)
 {
-    VkResult result;
-
     /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
     VkExtensionProperties *ext_props;
     uint32_t *count;
index 2f5e561..af1c478 100644 (file)
 #include "loader_platform.h"
 #include "vk_dispatch_table_helper.h"
 #include "vk_struct_string_helper_cpp.h"
+#if defined(__GNUC__)
 #pragma GCC diagnostic ignored "-Wwrite-strings"
+#endif
 #include "vk_struct_graphviz_helper.h"
+#if defined(__GNUC__)
 #pragma GCC diagnostic warning "-Wwrite-strings"
+#endif
 #include "vk_struct_size_helper.h"
 #include "draw_state.h"
 #include "layers_config.h"
@@ -1484,8 +1488,6 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
                                                size_t*  pDataSize,
                                                void*    pData)
 {
-    VkResult result;
-
     /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
     VkExtensionProperties *ext_props;
     uint32_t *count;
index 45bea6f..0da8996 100644 (file)
@@ -500,12 +500,12 @@ static bool32_t deleteCBInfoList()
 // For given MemObjInfo, report Obj & CB bindings
 static void reportMemReferencesAndCleanUp(MT_MEM_OBJ_INFO* pMemObjInfo)
 {
-    uint32_t cmdBufRefCount = pMemObjInfo->pCmdBufferBindings.size();
-    uint32_t objRefCount    = pMemObjInfo->pObjBindings.size();
+    size_t cmdBufRefCount = pMemObjInfo->pCmdBufferBindings.size();
+    size_t objRefCount    = pMemObjInfo->pObjBindings.size();
 
     if ((pMemObjInfo->pCmdBufferBindings.size() + pMemObjInfo->pObjBindings.size()) != 0) {
         char str[1024];
-        sprintf(str, "Attempting to free memory object %p which still contains %d references", pMemObjInfo->mem, (cmdBufRefCount + objRefCount));
+        sprintf(str, "Attempting to free memory object %p which still contains %lu references", pMemObjInfo->mem, (cmdBufRefCount + objRefCount));
         layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pMemObjInfo->mem, 0, MEMTRACK_INTERNAL_ERROR, "MEM", str);
     }
 
@@ -915,8 +915,6 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
                                                size_t*  pDataSize,
                                                void*    pData)
 {
-    VkResult result;
-
     /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
     VkExtensionProperties *ext_props;
     uint32_t *count;
@@ -995,7 +993,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueAddMemReferences(VkQueue queue, uint32_t c
             sprintf(str, "Unknown Queue %p", queue);
             layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_INVALID_QUEUE, "MEM", str);
         } else {
-            for (int i = 0; i < count; i++) {
+            for (uint32_t i = 0; i < count; i++) {
                 if (checkMemRef(queue, pMems[i]) == VK_TRUE) {
                     // Alread in list, just warn
                     char str[1024];
@@ -1025,7 +1023,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueRemoveMemReferences(VkQueue queue, uint32_
             sprintf(str, "Unknown Queue %p", queue);
             layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, queue, 0, MEMTRACK_INVALID_QUEUE, "MEM", str);
         } else {
-            for (int i = 0; i < count; i++) {
+            for (uint32_t i = 0; i < count; i++) {
                 for (list<VkDeviceMemory>::iterator it = pQueueInfo->pMemRefList.begin(); it != pQueueInfo->pMemRefList.end(); ++it) {
                     if ((*it) == pMems[i]) {
                         it = pQueueInfo->pMemRefList.erase(it);
index 1640dc6..b26e67d 100644 (file)
@@ -267,8 +267,6 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
                                                size_t*  pDataSize,
                                                void*    pData)
 {
-    VkResult result;
-
     /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
     VkExtensionProperties *ext_props;
     uint32_t *count;
index 3171baf..73a505f 100644 (file)
@@ -261,8 +261,6 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
                                                size_t*  pDataSize,
                                                void*    pData)
 {
-    VkResult result;
-
     /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
     VkExtensionProperties *ext_props;
     uint32_t *count;
index e65ea95..0a82e73 100644 (file)
@@ -91,9 +91,7 @@ xcb_connection_t * xcb_connect(const char *displayname, int *screenp)
     if (!module) {
         // TODO: Adapted up the following code (copied from "loader.c"):
         char *registry_str = NULL;
-        DWORD registry_len = 0;
-        DWORD registry_value_type;
-        LONG  registry_return_value;
+        size_t registry_len = 0;
         char *rtn_str = NULL;
         size_t rtn_len;
 
index 7c7597e..2a0ff72 100644 (file)
@@ -127,7 +127,7 @@ char *loader_get_registry_string(const HKEY hive,
     HKEY key;
     LONG  rtn_value;
     char *rtn_str = NULL;
-    size_t rtn_len = 0;
+    DWORD rtn_len = 0;
     size_t allocated_len = 0;
 
     rtn_value = RegOpenKeyEx(hive, sub_key, 0, access_flags, &key);
@@ -177,7 +177,7 @@ static char *loader_get_registry_and_env(const char *env_var,
     char *env_str = getenv(env_var);
     size_t env_len = (env_str == NULL) ? 0 : strlen(env_str);
     char *registry_str = NULL;
-    DWORD registry_len = 0;
+    size_t registry_len = 0;
     char *rtn_str = NULL;
     size_t rtn_len;
 
@@ -363,7 +363,7 @@ static bool loader_is_extension_scanned(const char *name)
     return false;
 }
 
-static void loader_coalesce_extensions()
+static void loader_coalesce_extensions(void)
 {
     uint32_t i;
     struct loader_scanned_icds *icd_list = loader.scanned_icd_list;
index 550ebc1..75ced76 100755 (executable)
@@ -140,7 +140,7 @@ class LoaderEntrypointsSubcommand(Subcommand):
             cond = ("%s == VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI && "
                     "%s && %s" % (ptype, pdata, cond))
             setup.append("VkDisplayPropertiesWSI *info = %s;" % pdata)
-            setup.append("uint32_t count = *%s / sizeof(*info), i;" % psize)
+            setup.append("size_t count = *%s / sizeof(*info), i;" % psize)
             setup.append("for (i = 0; i < count; i++) {")
             setup.append("    %s(info[i].display, disp);" % method)
             setup.append("}")
@@ -151,7 +151,7 @@ class LoaderEntrypointsSubcommand(Subcommand):
             cond = ("%s == VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI && "
                     "%s && %s" % (ptype, pdata, cond))
             setup.append("VkSwapChainImageInfoWSI *info = %s;" % pdata)
-            setup.append("uint32_t count = *%s / sizeof(*info), i;" % psize)
+            setup.append("size_t count = *%s / sizeof(*info), i;" % psize)
             setup.append("for (i = 0; i < count; i++) {")
             setup.append("    %s(info[i].image, disp);" % method)
             setup.append("    %s(info[i].memory, disp);" % method)
index e97243b..5a19ddf 100755 (executable)
@@ -1341,7 +1341,6 @@ class ThreadingSubcommand(Subcommand):
         if proto.name == "EnumerateLayers":
             funcs.append('%s%s\n'
                      '{\n'
-                     '    char str[1024];\n'
                      '    if (gpu != NULL) {\n'
                      '        pCurObj = (VkBaseLayerObject *) %s;\n'
                      '        loader_platform_thread_once(&tabOnce, init%s);\n'