[Piglit] [PATCH v2] ext_packed_depth_stencil: Fix Clang absolute-value warning.

Vinson Lee vlee at freedesktop.org
Sat Mar 28 21:15:07 PDT 2015


readpixels-24_8.c:62:6: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
            abs((value >> 8) - (expected >> 8)) > 1) {
            ^
readpixels-24_8.c:62:6: note: remove the call to 'abs' since unsigned values cannot be negative
            abs((value >> 8) - (expected >> 8)) > 1) {
            ^~~

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 tests/spec/ext_packed_depth_stencil/readpixels-24_8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
index 7fb9ad8..08288ca 100644
--- a/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
+++ b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
@@ -59,7 +59,7 @@ test_pixel(int x, int y, uint32_t value)
 
 	/* Compare depth and stencil separately. Use 1-bit tolerance for depth. */
 	if ((value & 0xff) - (expected & 0xff) != 0 ||
-	    abs((value >> 8) - (expected >> 8)) > 1) {
+	    abs((int32_t) (value >> 8) - (int32_t) (expected >> 8)) > 1) {
 		fprintf(stderr,
 			"Expected 0x%08x at (%d,%d), found 0x%08x\n",
 			expected, x, y, value);
-- 
2.1.0



More information about the Piglit mailing list