From 09eb2a402303b89727b6eae0d56c18f2b90b50b0 Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Tue, 18 Oct 2022 16:10:43 +0100 Subject: [PATCH] pvr: Add missing valgrind includes and fix unused return value. On including the header the compiler started throwing warnings about the return value not being used when setting and getting the vbits. This commit adds the missing valgrind related headers and fixes the warnings caused by including them. Signed-off-by: Karmjit Mahil Reviewed-by: Matt Coster Part-of: --- src/imagination/vulkan/pvr_bo.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/imagination/vulkan/pvr_bo.c b/src/imagination/vulkan/pvr_bo.c index e23ecf7e3cc..682491f1526 100644 --- a/src/imagination/vulkan/pvr_bo.c +++ b/src/imagination/vulkan/pvr_bo.c @@ -28,6 +28,11 @@ #include #include +#if defined(HAVE_VALGRIND) +# include +# include +#endif + #include "pvr_bo.h" #include "pvr_debug.h" #include "pvr_dump.h" @@ -443,10 +448,13 @@ void pvr_bo_cpu_unmap(struct pvr_device *device, struct pvr_bo *pvr_bo) bo->size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - if (bo->vbits) - VALGRIND_GET_VBITS(bo->map, bo->vbits, bo->size); - else + if (bo->vbits) { + unsigned ret = VALGRIND_GET_VBITS(bo->map, bo->vbits, bo->size); + if (ret != 0 && ret != 1) + mesa_loge("Failed to get vbits; expect bad valgrind results."); + } else { mesa_loge("Failed to alloc vbits storage; expect bad valgrind results."); + } #endif /* defined(HAVE_VALGRIND) */ device->ws->ops->buffer_unmap(bo); @@ -485,10 +493,15 @@ void pvr_bo_free(struct pvr_device *device, struct pvr_bo *pvr_bo) #if defined(HAVE_VALGRIND) void *pvr_bo_cpu_map_unchanged(struct pvr_device *device, struct pvr_bo *pvr_bo) { - void *ret = pvr_bo_cpu_map(device, pvr_bo); - if (ret) - VALGRIND_SET_VBITS(pvr_bo->bo->map, pvr_bo->bo->vbits, pvr_bo->bo->size); + void *map = pvr_bo_cpu_map(device, pvr_bo); + if (map) { + unsigned ret = VALGRIND_SET_VBITS(pvr_bo->bo->map, + pvr_bo->bo->vbits, + pvr_bo->bo->size); + if (ret != 0 && ret != 1) + mesa_loge("Failed to set vbits; expect bad valgrind results."); + } - return ret; + return map; } #endif /* defined(HAVE_VALGRIND) */