[PATCH 1/6] d3d9/tests: Fix color_match().

Matteo Bruni mbruni at codeweavers.com
Wed Oct 7 18:26:41 CDT 2015


Clang on OS X complains about calling abs() on an unsigned value and
I think it has a point since technically the unsigned to signed
conversion is implementation-dependent when the value can't be
represented in the signed integer type (i.e. for the "negative" numbers).

This probably doesn't fix any actual bug, at least Clang on OS X (Apple
LLVM 6.1.0) and gcc 4.8.5 on x86 Linux do the right thing anyway.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 dlls/d3d9/tests/visual.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index a9b1ade..49f3ad4 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -65,13 +65,13 @@ static HWND create_window(void)
 
 static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
 {
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (abs((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE;
     c1 >>= 8; c2 >>= 8;
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (abs((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE;
     c1 >>= 8; c2 >>= 8;
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (abs((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE;
     c1 >>= 8; c2 >>= 8;
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (abs((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE;
     return TRUE;
 }
 
-- 
2.4.9




More information about the wine-patches mailing list