[Mesa-dev] [PATCH 3/3] glsl/cache/tests: Cast cache_get result to avoid compiler warning

Aaron Watry awatry at gmail.com
Tue Nov 22 18:46:46 UTC 2016


disk_cache_get returns void*, but we were storing/comparing a char*.

Signed-off-by: Aaron Watry <awatry at gmail.com>
---
Note that this did, and still, segfaults for me when I actually run it...

But at least the compiler is no longer complaining about the type mismatch.
 src/compiler/glsl/tests/cache_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c
index 0ef05aa..c663e54 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -208,14 +208,14 @@ test_put_and_get(void)
    _mesa_sha1_compute(blob, sizeof(blob), blob_key);
 
    /* Ensure that disk_cache_get returns nothing before anything is added. */
-   result = disk_cache_get(cache, blob_key, &size);
+   result = (char*) disk_cache_get(cache, blob_key, &size);
    expect_null(result, "disk_cache_get with non-existent item (pointer)");
    expect_equal(size, 0, "disk_cache_get with non-existent item (size)");
 
    /* Simple test of put and get. */
    disk_cache_put(cache, blob_key, blob, sizeof(blob));
 
-   result = disk_cache_get(cache, blob_key, &size);
+   result = (char*) disk_cache_get(cache, blob_key, &size);
    expect_equal_str(blob, result, "disk_cache_get of existing item (pointer)");
    expect_equal(size, sizeof(blob), "disk_cache_get of existing item (size)");
 
@@ -225,7 +225,7 @@ test_put_and_get(void)
    _mesa_sha1_compute(string, sizeof(string), string_key);
    disk_cache_put(cache, string_key, string, sizeof(string));
 
-   result = disk_cache_get(cache, string_key, &size);
+   result = (char*) disk_cache_get(cache, string_key, &size);
    expect_equal_str(result, string, "2nd disk_cache_get of existing item (pointer)");
    expect_equal(size, sizeof(string), "2nd disk_cache_get of existing item (size)");
 
-- 
2.7.4



More information about the mesa-dev mailing list