From: Mun, Gwan-gyeong Date: Mon, 18 Apr 2016 11:15:36 +0000 (+0900) Subject: etc: Fix int to pointer typecasting build warnings X-Git-Tag: submit/submit/tizen/20170906.070327/20170906.070422~52^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=12a32d51ceef9119ed5e4430ca53ad2e1f6e2a72;p=platform%2Fcore%2Fuifw%2Fvulkan-wsi-tizen.git etc: Fix int to pointer typecasting build warnings 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 --- diff --git a/src/null-driver/null-driver.c b/src/null-driver/null-driver.c index 6f9fa84..5ee2f8d 100644 --- a/src/null-driver/null-driver.c +++ b/src/null-driver/null-driver.c @@ -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; } diff --git a/src/wsi/surface.c b/src/wsi/surface.c index 1636268..09003e6 100644 --- a/src/wsi/surface.c +++ b/src/wsi/surface.c @@ -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, diff --git a/src/wsi/swapchain.c b/src/wsi/swapchain.c index 5b1387d..368d819 100644 --- a/src/wsi/swapchain.c +++ b/src/wsi/swapchain.c @@ -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;