[Piglit] [PATCH v2] select: Fix Clang absolute-value warnings.

Vinson Lee vlee at freedesktop.org
Tue Jun 14 22:04:30 UTC 2016


select.c:126:10: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
        diffz = abs(hit1[MIN_Z] - hit2[MIN_Z])/zscale;
                ^
select.c:126:10: note: remove the call to 'abs' since unsigned values cannot be negative
        diffz = abs(hit1[MIN_Z] - hit2[MIN_Z])/zscale;
                ^~~
select.c:138:10: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
        diffz = abs(hit1[MAX_Z] - hit2[MAX_Z])/zscale;
                ^
select.c:138:10: note: remove the call to 'abs' since unsigned values cannot be negative
        diffz = abs(hit1[MAX_Z] - hit2[MAX_Z])/zscale;
                ^~~

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 tests/general/select.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/general/select.c b/tests/general/select.c
index 879a1e9..aadf2ef 100644
--- a/tests/general/select.c
+++ b/tests/general/select.c
@@ -123,7 +123,7 @@ compare_hit_record(GLuint* hit1, GLuint* hit2)
 		return false;
 	}
 
-	diffz = abs(hit1[MIN_Z] - hit2[MIN_Z])/zscale;
+	diffz = abs((GLint) hit1[MIN_Z] - (GLint) hit2[MIN_Z])/zscale;
 	if (diffz > 0.1) {
 		printf("\t%s : Incorrect Minz : %u %u (%f %f) %f\n",
 			__FUNCTION__,
@@ -135,7 +135,7 @@ compare_hit_record(GLuint* hit1, GLuint* hit2)
 		return false;
 	}
 
-	diffz = abs(hit1[MAX_Z] - hit2[MAX_Z])/zscale;
+	diffz = abs((GLint) hit1[MAX_Z] - (GLint) hit2[MAX_Z])/zscale;
 	if (diffz > 0.1) {
 		printf("\t%s : Incorrect Maxz : %u %u (%f %f) %f\n",
 			__FUNCTION__,
-- 
2.1.0



More information about the Piglit mailing list