From: Dave Airlie Date: Fri, 12 Apr 2019 07:04:48 +0000 (+1000) Subject: cube: fix scoping of some variables. X-Git-Tag: upstream/1.2.179~275 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48a68f9a2689faab7feb8149684356ca29d09c42;p=platform%2Fupstream%2FVulkan-Tools.git cube: fix scoping of some variables. use_invalid: Using "present.pNext", which points to an out-of-scope variable "regions". In theory these local vars are out of scope when they are used later. Pointed out by coverity --- diff --git a/cube/cube.c b/cube/cube.c index 7ba4c7c..e4d59fa 100644 --- a/cube/cube.c +++ b/cube/cube.c @@ -1084,6 +1084,9 @@ static void demo_draw(struct demo *demo) { .pImageIndices = &demo->current_buffer, }; + VkRectLayerKHR rect; + VkPresentRegionKHR region; + VkPresentRegionsKHR regions; if (demo->VK_KHR_incremental_present_enabled) { // If using VK_KHR_incremental_present, we provide a hint of the region // that contains changed content relative to the previously-presented @@ -1093,23 +1096,20 @@ static void demo_draw(struct demo *demo) { // ensure that the entire image has the correctly-drawn content. uint32_t eighthOfWidth = demo->width / 8; uint32_t eighthOfHeight = demo->height / 8; - VkRectLayerKHR rect = { - .offset.x = eighthOfWidth, - .offset.y = eighthOfHeight, - .extent.width = eighthOfWidth * 6, - .extent.height = eighthOfHeight * 6, - .layer = 0, - }; - VkPresentRegionKHR region = { - .rectangleCount = 1, - .pRectangles = &rect, - }; - VkPresentRegionsKHR regions = { - .sType = VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR, - .pNext = present.pNext, - .swapchainCount = present.swapchainCount, - .pRegions = ®ion, - }; + + rect.offset.x = eighthOfWidth; + rect.offset.y = eighthOfHeight; + rect.extent.width = eighthOfWidth * 6; + rect.extent.height = eighthOfHeight * 6; + rect.layer = 0; + + region.rectangleCount = 1; + region.pRectangles = ▭ + + regions.sType = VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR; + regions.pNext = present.pNext; + regions.swapchainCount = present.swapchainCount; + regions.pRegions = ®ion; present.pNext = ®ions; }