From eb430aa9e7fdc99a5f984bc2fb5193f5c02d88ad Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Tue, 2 Nov 2021 20:38:33 -0700 Subject: [PATCH] anv: Get rid of "may be used initialized" warning in anv_QueueSubmit2KHR MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The code is correct, but compiler can't see it. Initialize the value to NULL and assert on it if the function succeeds. It both helps the compiler and make the code slightly more robust. ``` ../src/intel/vulkan/anv_queue.c: In function ‘anv_QueueSubmit2KHR’: ../src/intel/vulkan/anv_queue.c:932:16: warning: ‘impl’ may be used uninitialized in this function [-Wmaybe-uninitialized] 932 | result = anv_queue_submit_add_timeline_wait(queue, submit, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 933 | &impl->timeline, | ~~~~~~~~~~~~~~~~ 934 | value); | ~~~~~~ ../src/intel/vulkan/anv_queue.c:899:31: note: ‘impl’ was declared here 899 | struct anv_semaphore_impl *impl; | ^~~~ ``` Reviewed-by: Jordan Justen Part-of: --- src/intel/vulkan/anv_queue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index d485aee..714267a 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -896,13 +896,15 @@ anv_queue_submit_add_in_semaphore(struct anv_queue *queue, const uint64_t value) { ANV_FROM_HANDLE(anv_semaphore, semaphore, _semaphore); - struct anv_semaphore_impl *impl; + struct anv_semaphore_impl *impl = NULL; VkResult result; result = maybe_transfer_temporary_semaphore(queue, submit, semaphore, &impl); if (result != VK_SUCCESS) return result; + assert(impl); + switch (impl->type) { case ANV_SEMAPHORE_TYPE_WSI_BO: /* When using a window-system buffer as a semaphore, always enable -- 2.7.4