Mesa (main): gallium/tests: Fix warning calculating absdiff
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 28 16:48:45 UTC 2021
Module: Mesa
Branch: main
Commit: c0d5c06fed44396c7fc7b8cb24b1db8cfec8f535
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c0d5c06fed44396c7fc7b8cb24b1db8cfec8f535
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Tue Jul 27 16:44:09 2021 -0400
gallium/tests: Fix warning calculating absdiff
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 <alyssa at collabora.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12087>
---
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 {
More information about the mesa-commit
mailing list