Module: wine Branch: master Commit: 468ace0c506c2b1801670f67324713cfececec2b URL: https://gitlab.winehq.org/wine/wine/-/commit/468ace0c506c2b1801670f67324713c...
Author: Jeff Smith whydoubt@gmail.com Date: Wed Aug 2 22:48:17 2023 -0500
d3drm/tests: Use compare_uint() in compare_float() instead of abs().
The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison.
---
dlls/d3drm/tests/d3drm.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 1dfddc25a64..2dc06d11383 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -44,6 +44,13 @@ static ULONG get_refcount(IUnknown *object) return IUnknown_Release( object ); }
+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 compare_float(float f, float g, unsigned int ulps) { int x = *(int *)&f; @@ -54,10 +61,7 @@ static BOOL compare_float(float f, float g, unsigned int ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
#define expect_matrix(m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u) \ @@ -103,13 +107,6 @@ static void vector_eq_(unsigned int line, const D3DVECTOR *left, const D3DVECTOR expect_vector_(line, left, U1(*right).x, U2(*right).y, U3(*right).z, 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 compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) { return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)