Signed-off-by: Chip Davis cdavis@codeweavers.com --- v2: Fold absdiff() into a compare_uint() helper. --- dlls/d3d8/tests/device.c | 4 ++-- dlls/d3d8/tests/visual.c | 15 +++++++++++---- 2 files changed, 13 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..033c92e6276 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -51,15 +51,22 @@ static HWND create_window(void) 0, 0, rect.right - rect.left, rect.bottom - rect.top, 0, 0, 0, 0); }
+static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) +{ + unsigned int diff = x > y ? x - y : y - x; + + return diff <= max_diff; +} + static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) { - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE; c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE; c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE; c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE; return TRUE; }