Mesa (master): util/disk_cache: close fd in the fallback path

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 28 16:41:58 UTC 2019


Module: Mesa
Branch: master
Commit: 7fefa4610d96bc65322c73879da83b24487b2c90
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fefa4610d96bc65322c73879da83b24487b2c90

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Tue Mar 19 14:36:30 2019 +0000

util/disk_cache: close fd in the fallback path

There are multiple `goto path_fail` with an open fd, but none that go to
`fail:` without going through `path_fail:` first, so let's just move the
`close(fd)` there.

Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/util/disk_cache.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 0aa2646a9bb..9977c385de1 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -330,8 +330,6 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
       goto path_fail;
    cache->index_mmap_size = size;
 
-   close(fd);
-
    cache->size = (uint64_t *) cache->index_mmap;
    cache->stored_keys = cache->index_mmap + sizeof(uint64_t);
 
@@ -385,6 +383,9 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
 
  path_fail:
 
+   if (fd != -1)
+      close(fd);
+
    cache->driver_keys_blob_size = cv_size;
 
    /* Create driver id keys */
@@ -423,8 +424,6 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
    return cache;
 
  fail:
-   if (fd != -1)
-      close(fd);
    if (cache)
       ralloc_free(cache);
    ralloc_free(local);




More information about the mesa-commit mailing list