From: Caio Marcelo de Oliveira Filho Date: Wed, 3 Nov 2021 03:38:33 +0000 (-0700) Subject: anv: Get rid of "may be used initialized" warning in anv_QueueSubmit2KHR X-Git-Tag: upstream/22.3.5~16053 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb430aa9e7fdc99a5f984bc2fb5193f5c02d88ad;p=platform%2Fupstream%2Fmesa.git anv: Get rid of "may be used initialized" warning in anv_QueueSubmit2KHR 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: --- 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