[Piglit] [PATCH 2/4] util: Fix an -Wabsolute-value warning

Chad Versace chad.versace at linux.intel.com
Wed Jul 9 14:47:50 PDT 2014


To fix the warning below, cast uint to int.

tests/util/piglit-util-gl-common.c:1273:9: warning: taking the absolute value \
of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
    if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 tests/util/piglit-util-gl-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c
index 83e78fc..cadf714 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1270,7 +1270,7 @@ piglit_probe_rect_rgba_uint(int x, int y, int w, int h,
 			probe = &pixels[(j*w+i)*4];
 
 			for (p = 0; p < 4; ++p) {
-				if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
+				if (abs((int) (probe[p] - expected[p])) >= piglit_tolerance[p]) {
 					printf("Probe color at (%d,%d)\n", x+i, y+j);
 					printf("  Expected: %u %u %u %u\n",
 					       expected[0], expected[1], expected[2], expected[3]);
-- 
2.0.0



More information about the Piglit mailing list