[PATCH 4/5] d3d8/tests: Fix absolute value warnings. (Clang)

Chip Davis cdavis at codeweavers.com
Thu Mar 26 02:46:06 CDT 2020


Signed-off-by: Chip Davis <cdavis at codeweavers.com>
---
 dlls/d3d8/tests/device.c |  4 ++--
 dlls/d3d8/tests/visual.c | 13 +++++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index d87832b716d..26687af5f15 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -1294,8 +1294,8 @@ static int compare_mode(const void *a, const void *b)
 {
     const struct mode *mode_a = a;
     const struct mode *mode_b = b;
-    unsigned int w = mode_a->w - mode_b->w;
-    unsigned int h = mode_a->h - mode_b->h;
+    int w = mode_a->w - mode_b->w;
+    int h = mode_a->h - mode_b->h;
     return abs(w) >= abs(h) ? -w : -h;
 }
 
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index ab194b9cedf..30d8eb231bc 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -51,15 +51,20 @@ static HWND create_window(void)
             0, 0, rect.right - rect.left, rect.bottom - rect.top, 0, 0, 0, 0);
 }
 
+static inline unsigned int absdiff(unsigned int a, unsigned int b)
+{
+    return a > b ? a - b : b - a;
+}
+
 static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
 {
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (absdiff(c1 & 0xff, c2 & 0xff) > max_diff) return FALSE;
     c1 >>= 8; c2 >>= 8;
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (absdiff(c1 & 0xff, c2 & 0xff) > max_diff) return FALSE;
     c1 >>= 8; c2 >>= 8;
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (absdiff(c1 & 0xff, c2 & 0xff) > max_diff) return FALSE;
     c1 >>= 8; c2 >>= 8;
-    if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+    if (absdiff(c1 & 0xff, c2 & 0xff) > max_diff) return FALSE;
     return TRUE;
 }
 
-- 
2.24.0




More information about the wine-devel mailing list