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@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12087>
This commit is contained in:
Alyssa Rosenzweig 2021-07-27 16:44:09 -04:00 committed by Marge Bot
parent f1a66e7c90
commit c0d5c06fed
1 changed files with 7 additions and 2 deletions

View File

@ -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 {