Mesa (main): anv: Get rid of "may be used initialized" warning in anv_QueueSubmit2KHR

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 3 17:27:36 UTC 2021


Module: Mesa
Branch: main
Commit: eb430aa9e7fdc99a5f984bc2fb5193f5c02d88ad
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb430aa9e7fdc99a5f984bc2fb5193f5c02d88ad

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Tue Nov  2 20:38:33 2021 -0700

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 <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13638>

---

 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 d485aeeb51a..714267ac2c3 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



More information about the mesa-commit mailing list