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

Matt Turner mattst88 at gmail.com
Tue Nov 22 20:48:25 UTC 2016


On 11/22, Aaron Watry wrote:
>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...

Strange. It passes for me.

>
>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);

void * is implicitly convertable to char *, so I think the code is fine
as is. Maybe if I saw the compiler warning.

"result" could be declared void * to begin with, and that would be fine.
I just tested it, and it seems to work.

Also, please use (char *) for casts and not (char*) in Mesa.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161122/9fe02998/attachment.sig>


More information about the mesa-dev mailing list