aboutsummaryrefslogtreecommitdiff
path: root/cube/cube.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2019-04-12 17:04:48 +1000
committerjeremyk-lunarg <jeremyk@lunarg.com>2019-04-23 13:19:30 -0600
commit48a68f9a2689faab7feb8149684356ca29d09c42 (patch)
tree38cca30d5538c8be0a900ae6a5628f12090d97d4 /cube/cube.c
parenta0dab53f451d0c3a39f5d9b0fa062dbca00a4290 (diff)
downloadusermoji-48a68f9a2689faab7feb8149684356ca29d09c42.tar.xz
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
Diffstat (limited to 'cube/cube.c')
-rw-r--r--cube/cube.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/cube/cube.c b/cube/cube.c
index 7ba4c7cf..e4d59fa0 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 = &region,
- };
+
+ 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 = &rect;
+
+ regions.sType = VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR;
+ regions.pNext = present.pNext;
+ regions.swapchainCount = present.swapchainCount;
+ regions.pRegions = &region;
present.pNext = &regions;
}