Jacek Caban : quartz/tests: Fix -Wabsolute-value warnings.
Alexandre Julliard
julliard at winehq.org
Mon Jun 1 15:14:55 CDT 2020
Module: wine
Branch: master
Commit: 2ad5d4f159ef447c288fc9463fa7e50a8342a612
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2ad5d4f159ef447c288fc9463fa7e50a8342a612
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu May 28 00:38:09 2020 +0200
quartz/tests: Fix -Wabsolute-value warnings.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/quartz/tests/filtergraph.c | 18 ++++++++++++------
dlls/quartz/tests/systemclock.c | 8 +++++++-
dlls/quartz/tests/vmr9.c | 21 +++++++++++----------
3 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index 68b4863442..f0aa084192 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -41,6 +41,12 @@ typedef struct TestFilterImpl
UINT nPins;
} TestFilterImpl;
+static BOOL compare_time(ULONGLONG x, ULONGLONG y, unsigned int max_diff)
+{
+ ULONGLONG diff = x > y ? x - y : y - x;
+ return diff <= max_diff;
+}
+
static WCHAR *create_file(const WCHAR *name, const char *data, DWORD size)
{
static WCHAR pathW[MAX_PATH];
@@ -4057,13 +4063,13 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time);
ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */
- ok(abs(time - 1234 * 10000) < 40 * 10000,
+ ok(compare_time(time, 1234 * 10000, 40 * 10000),
"Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */
- ok(abs(current - 1234 * 10000) < 40 * 10000,
+ ok(compare_time(current, 1234 * 10000, 40 * 10000),
"Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(current));
ok(stop == 9000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
@@ -4080,13 +4086,13 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time);
ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */
- ok(abs(time - 1334 * 10000) < 80 * 10000,
+ ok(compare_time(time, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */
- ok(abs(current - 1334 * 10000) < 80 * 10000,
+ ok(compare_time(current, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current));
ok(stop == 8000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
@@ -4100,13 +4106,13 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time);
ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */
- ok(abs(time - 1334 * 10000) < 80 * 10000,
+ ok(compare_time(time, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */
- ok(abs(current - 1334 * 10000) < 80 * 10000,
+ ok(compare_time(current, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current));
ok(stop == 8000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
diff --git a/dlls/quartz/tests/systemclock.c b/dlls/quartz/tests/systemclock.c
index b85a801f0e..71a7ac26d8 100644
--- a/dlls/quartz/tests/systemclock.c
+++ b/dlls/quartz/tests/systemclock.c
@@ -24,6 +24,12 @@
static ULONGLONG (WINAPI *pGetTickCount64)(void);
+static BOOL compare_time(REFERENCE_TIME x, REFERENCE_TIME y, unsigned int max_diff)
+{
+ REFERENCE_TIME diff = x > y ? x - y : y - x;
+ return diff <= max_diff;
+}
+
static IReferenceClock *create_system_clock(void)
{
IReferenceClock *clock = NULL;
@@ -181,7 +187,7 @@ static void test_get_time(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time1 % 10000 == 0, "Expected no less than 1ms coarseness, but got time %s.\n",
wine_dbgstr_longlong(time1));
- ok(abs(time1 - time2) < 20 * 10000, "Expected about %s, got %s.\n",
+ ok(compare_time(time1, time2, 20 * 10000), "Expected about %s, got %s.\n",
wine_dbgstr_longlong(time2), wine_dbgstr_longlong(time1));
hr = IReferenceClock_GetTime(clock, &time2);
diff --git a/dlls/quartz/tests/vmr9.c b/dlls/quartz/tests/vmr9.c
index 2921d1aed0..7dd6dbe1dd 100644
--- a/dlls/quartz/tests/vmr9.c
+++ b/dlls/quartz/tests/vmr9.c
@@ -73,18 +73,19 @@ static inline BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TY
static BOOL compare_double(double f, double g, unsigned int ulps)
{
- int64_t x = *(int64_t *)&f;
- int64_t y = *(int64_t *)&g;
+ uint64_t x = *(ULONGLONG *)&f;
+ uint64_t y = *(ULONGLONG *)&g;
- if (x < 0)
- x = INT64_MIN - x;
- if (y < 0)
- y = INT64_MIN - y;
-
- if (abs(x - y) > ulps)
- return FALSE;
+ if (f < 0)
+ x = ~x + 1;
+ else
+ x |= ((ULONGLONG)1)<<63;
+ if (g < 0)
+ y = ~y + 1;
+ else
+ y |= ((ULONGLONG)1)<<63;
- return TRUE;
+ return (x>y ? x-y : y-x) <= ulps;
}
static IFilterGraph2 *create_graph(void)
More information about the wine-cvs
mailing list