etc: Fix int to pointer typecasting build warnings 73/66373/4
authorMun, Gwan-gyeong <kk.moon@samsung.com>
Mon, 18 Apr 2016 11:15:36 +0000 (20:15 +0900)
committerTaekyun Kim <tkq.kim@samsung.com>
Tue, 19 Apr 2016 03:44:27 +0000 (20:44 -0700)
This is a bug from the khronos vulkan header file. It is scheduled to be resolved in
milestone "P1". See the following issue page.

https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/36

When we use typecasting to pointer type, we should use uintptr_t type. it provides
safe pointer typecasting on 32bit and 64bit. We can revert this commit when the
above issue is resolved.

Change-Id: Id53d17c13c0dafc341889875140469c0f2943e67

src/null-driver/null-driver.c
src/wsi/surface.c
src/wsi/swapchain.c

index 6f9fa84..5ee2f8d 100644 (file)
@@ -1739,7 +1739,7 @@ get_buffer_memory_requirements(VkDevice device,
                                                           VkMemoryRequirements *memory_requirements)
 {
        NULLDRV_LOG_FUNC;
-       struct nulldrv_base *base = nulldrv_base((void*)buffer);
+       struct nulldrv_base *base = nulldrv_base((void*)(uintptr_t)buffer);
 
        base->get_memory_requirements(base, memory_requirements);
 }
@@ -1750,7 +1750,7 @@ get_image_memory_requirements(VkDevice device,
                                                          VkMemoryRequirements *memory_requirements)
 {
        NULLDRV_LOG_FUNC;
-       struct nulldrv_base *base = nulldrv_base((void*)image);
+       struct nulldrv_base *base = nulldrv_base((void*)(uintptr_t)image);
 
        base->get_memory_requirements(base, memory_requirements);
 }
@@ -1825,7 +1825,7 @@ create_pipeline_cache(VkDevice device,
        if (!pipeline_cache)
                return VK_ERROR_OUT_OF_HOST_MEMORY;
 
-       *cache = (VkPipelineCache) pipeline_cache;
+       *cache = (VkPipelineCache)(uintptr_t)pipeline_cache;
 
        return VK_SUCCESS;
 }
@@ -1998,7 +1998,7 @@ create_shader_module(VkDevice device,
        if (!shader_module)
                return VK_ERROR_OUT_OF_HOST_MEMORY;
 
-       *module = (VkShaderModule) shader_module;
+       *module = (VkShaderModule)(uintptr_t)shader_module;
 
        return VK_SUCCESS;
 }
@@ -2518,7 +2518,7 @@ vk_create_presentable_image(VkDevice device, const VkImageCreateInfo *info, tbm_
        struct nulldrv_img *img;
 
        if (nulldrv_img_create(dev, surface, info, false, &img) == VK_SUCCESS)
-               return (VkImage)img;
+               return (VkImage)(uintptr_t)img;
 
-       return NULL;
+       return (uintptr_t)NULL;
 }
index 1636268..09003e6 100644 (file)
@@ -49,7 +49,7 @@ vk_GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice                    pdev,
                                                                                   VkSurfaceKHR                          surface,
                                                                                   VkSurfaceCapabilitiesKHR     *caps)
 {
-       VkIcdSurfaceWayland     *sfc = (VkIcdSurfaceWayland *)surface;
+       VkIcdSurfaceWayland     *sfc = (VkIcdSurfaceWayland *)(uintptr_t)surface;
        tpl_display_t           *display;
 
        VK_CHECK(sfc->base.platform == VK_ICD_WSI_PLATFORM_WAYLAND, return VK_ERROR_DEVICE_LOST,
index 5b1387d..368d819 100644 (file)
@@ -34,7 +34,7 @@ vk_CreateSwapchainKHR(VkDevice                                                         device,
        vk_swapchain_t          *chain;
        tbm_format                       format;
        tpl_result_t             res;
-       VkIcdSurfaceWayland     *surface = (VkIcdSurfaceWayland *)info->surface;
+       VkIcdSurfaceWayland     *surface = (VkIcdSurfaceWayland *)(uintptr_t)info->surface;
        int                                      buffer_count, i;
        tbm_surface_h           *buffers;
 
@@ -107,7 +107,7 @@ vk_CreateSwapchainKHR(VkDevice                                                       device,
        }
 
        chain->buffer_count = buffer_count;
-       *swapchain = (VkSwapchainKHR)chain;
+       *swapchain = (VkSwapchainKHR)(uintptr_t)chain;
        return VK_SUCCESS;
 
 error:
@@ -140,7 +140,7 @@ vk_DestroySwapchainKHR(VkDevice                                              device,
                                           VkSwapchainKHR                                swapchain,
                                           const VkAllocationCallbacks  *allocator)
 {
-       vk_swapchain_t *chain = (vk_swapchain_t *)swapchain;
+       vk_swapchain_t *chain = (vk_swapchain_t *)(uintptr_t)swapchain;
 
        tpl_surface_destroy_swapchain(chain->tpl_surface);
        free(chain->buffers);
@@ -160,7 +160,7 @@ vk_GetSwapchainImagesKHR(VkDevice            device,
                                                 uint32_t               *image_count,
                                                 VkImage                *images)
 {
-       vk_swapchain_t *chain = (vk_swapchain_t *)swapchain;
+       vk_swapchain_t *chain = (vk_swapchain_t *)(uintptr_t)swapchain;
 
        if (images) {
                uint32_t i;
@@ -191,7 +191,7 @@ vk_AcquireNextImageKHR(VkDevice                      device,
 
        uint32_t                 i;
        tbm_surface_h    next;
-       vk_swapchain_t  *chain = (vk_swapchain_t *)swapchain;
+       vk_swapchain_t  *chain = (vk_swapchain_t *)(uintptr_t)swapchain;
 
        next = tpl_surface_dequeue_buffer(chain->tpl_surface);
        VK_CHECK(next, return VK_ERROR_SURFACE_LOST_KHR, "tpl_surface_dequeue_buffers() failed\n.");
@@ -219,9 +219,9 @@ vk_QueuePresentKHR(VkQueue                                   queue,
                tbm_surface_h tbm;
                tbm_surface_info_s sinfo;
                int map_ret;
-               uint32_t color, k;
+               uint32_t color = 0, k;
 #endif
-               vk_swapchain_t  *chain = (vk_swapchain_t *)info->pSwapchains[i];
+               vk_swapchain_t  *chain = (vk_swapchain_t *)(uintptr_t)info->pSwapchains[i];
 
 #if 1 /* TODO: later remove this code section, it is needed just for Swapchaing debugging */
                VK_DEBUG("%s, tbm_surface: %p, index: %d\n", __func__,
@@ -231,7 +231,7 @@ vk_QueuePresentKHR(VkQueue                                   queue,
 
                map_ret = tbm_surface_map(tbm, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &sinfo);
                if (map_ret == TBM_SURFACE_ERROR_NONE) {
-                       uint32_t *ptr = sinfo.planes[0].ptr;
+                       uint32_t *ptr = (uint32_t *)sinfo.planes[0].ptr;
                        switch(info->pImageIndices[i]) {
                                case 0:
                                        color = 0xFFFF0000;