From c0d5c06fed44396c7fc7b8cb24b1db8cfec8f535 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 27 Jul 2021 16:44:09 -0400 Subject: [PATCH] gallium/tests: Fix warning calculating absdiff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With clang building tests: ../src/gallium/tests/trivial/compute.c:1215:29: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] if (abs(((uint32_t *)x)[j] - ^ ../src/gallium/tests/trivial/compute.c:1215:29: note: remove the call to 'abs' since unsigned values cannot be negative if (abs(((uint32_t *)x)[j] - Signed-off-by: Alyssa Rosenzweig Reviewed-by: Marek Olšák Part-of: --- src/gallium/tests/trivial/compute.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c index 5c57b1e5f4c..9c66a93ef96 100644 --- a/src/gallium/tests/trivial/compute.c +++ b/src/gallium/tests/trivial/compute.c @@ -1203,6 +1203,11 @@ static void test_surface_st_expectu(void *p, int s, int x, int y) util_format_pack_rgba(surface_fmts[i], p, v, 1); } +static unsigned absdiff(uint32_t a, uint32_t b) +{ + return (a > b) ? (a - b) : (b - a); +} + static bool test_surface_st_check(void *x, void *y, int sz) { int i = 0, j; @@ -1212,8 +1217,8 @@ static bool test_surface_st_check(void *x, void *y, int sz) } else if ((sz % 4) == 0) { for (j = 0; j < sz / 4; j++) - if (abs(((uint32_t *)x)[j] - - ((uint32_t *)y)[j]) > 1) + if (absdiff(((uint32_t *)x)[j], + ((uint32_t *)y)[j]) > 1) return false; return true; } else {