Fix some incorrect uses of ok macro.

Rein Klazes wijn at wanadoo.nl
Thu Mar 31 12:09:16 CST 2005


Hi,

Changelog:

dlls/user/tests		: win.c, msg.c
dlls/kernel/tests	: file.c

Fix some incorrect uses of the ok macro where the result depends on the
evaluation order of its arguments.

Rein.
-------------- next part --------------
--- wine/dlls/user/tests/win.c	2005-03-30 20:51:45.000000000 +0200
+++ mywine/dlls/user/tests/win.c	2005-03-31 17:29:49.000000000 +0200
@@ -2407,6 +2407,7 @@ static void test_nccalcscroll(HWND paren
 
 static void test_SetParent(void)
 {
+    BOOL ret;
     HWND desktop = GetDesktopWindow();
     BOOL is_win9x = GetWindowLongPtrW(desktop, GWLP_WNDPROC) == 0;
     HWND parent, child1, child2, child3, child4;
@@ -2475,7 +2476,8 @@ todo_wine {
         check_parents(child4, desktop, child2, child2, child2, child4, parent);
     }
 
-    ok(DestroyWindow(parent), "DestroyWindow() error %ld\n", GetLastError());
+    ret = DestroyWindow(parent);
+    ok( ret, "DestroyWindow() error %ld\n", GetLastError());
 
     ok(!IsWindow(parent), "parent still exists\n");
     ok(!IsWindow(child1), "child1 still exists\n");
--- wine/dlls/user/tests/msg.c	2005-03-30 20:51:44.000000000 +0200
+++ mywine/dlls/user/tests/msg.c	2005-03-31 17:16:24.000000000 +0200
@@ -5154,6 +5154,7 @@ static DWORD WINAPI cbt_global_hook_thre
 
 static void test_winevents(void)
 {
+    BOOL ret;
     MSG msg;
     HWND hwnd, hwnd2;
     UINT i;
@@ -5195,7 +5196,8 @@ static void test_winevents(void)
 
     ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
 
-    ok(UnhookWindowsHookEx(hCBT_global_hook), "UnhookWindowsHookEx error %ld", GetLastError());
+    ret = UnhookWindowsHookEx(hCBT_global_hook);
+    ok( ret, "UnhookWindowsHookEx error %ld", GetLastError());
 
     PostThreadMessageA(tid, WM_QUIT, 0, 0);
     ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
@@ -5256,7 +5258,8 @@ static void test_winevents(void)
 
     ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
 
-    ok(pUnhookWinEvent(hhook), "UnhookWinEvent error %ld\n", GetLastError());
+    ret = pUnhookWinEvent(hhook);
+    ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
 
     PostThreadMessageA(tid, WM_QUIT, 0, 0);
     ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
@@ -5301,7 +5304,8 @@ static void test_winevents(void)
     ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
     ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
 
-    ok(pUnhookWinEvent(hhook), "UnhookWinEvent error %ld\n", GetLastError());
+    ret = pUnhookWinEvent(hhook);
+    ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
 
     PostThreadMessageA(tid, WM_QUIT, 0, 0);
     ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
@@ -5315,6 +5319,7 @@ static void test_winevents(void)
 
 static void test_set_hook(void)
 {
+    BOOL ret;
     HHOOK hhook;
     HWINEVENTHOOK hwinevent_hook;
     HMODULE user32 = GetModuleHandleA("user32.dll");
@@ -5390,7 +5395,8 @@ static void test_set_hook(void)
 	0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
     ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
     ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
-    ok(pUnhookWinEvent(hwinevent_hook), "UnhookWinEvent error %ld\n", GetLastError());
+    ret = pUnhookWinEvent(hwinevent_hook);
+    ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
 
 todo_wine {
     /* This call succeeds under win2k SP4, but fails under Wine.
@@ -5400,7 +5406,8 @@ todo_wine {
 	0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
     ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
     ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
-    ok(pUnhookWinEvent(hwinevent_hook), "UnhookWinEvent error %ld\n", GetLastError());
+    ret = pUnhookWinEvent(hwinevent_hook);
+    ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
 }
 
     SetLastError(0xdeadbeef);
@@ -5506,6 +5513,7 @@ static const struct message destroy_wind
 
 static void test_DestroyWindow(void)
 {
+    BOOL ret;
     HWND parent, child1, child2, child3, child4, test;
     UINT child_id = WND_CHILD_ID + 1;
 
@@ -5606,7 +5614,8 @@ todo_wine {
     ok(test == child4, "wrong capture window %p\n", test);
 
     test_DestroyWindow_flag = TRUE;
-    ok(DestroyWindow(parent), "DestroyWindow() error %ld\n", GetLastError());
+    ret = DestroyWindow(parent);
+    ok( ret, "DestroyWindow() error %ld\n", GetLastError());
     test_DestroyWindow_flag = FALSE;
     ok_sequence(destroy_window_with_children, "destroy window with children", 0);
 
@@ -5696,6 +5705,7 @@ static void test_DispatchMessage(void)
 
 START_TEST(msg)
 {
+    BOOL ret;
     HMODULE user32 = GetModuleHandleA("user32.dll");
     FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
     FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
@@ -5729,7 +5739,8 @@ START_TEST(msg)
     test_winevents();
 
     /* Fix message sequences before removing 3 lines below */
-    ok(pUnhookWinEvent(hEvent_hook), "UnhookWinEvent error %ld\n", GetLastError());
+    ret = pUnhookWinEvent(hEvent_hook);
+    ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
     pUnhookWinEvent = 0;
     hEvent_hook = 0;
 
@@ -5749,7 +5760,8 @@ START_TEST(msg)
     UnhookWindowsHookEx(hCBT_hook);
     if (pUnhookWinEvent)
     {
-	ok(pUnhookWinEvent(hEvent_hook), "UnhookWinEvent error %ld\n", GetLastError());
+	ret = pUnhookWinEvent(hEvent_hook);
+	ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
 	SetLastError(0xdeadbeef);
 	ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
 	ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
--- wine/dlls/kernel/tests/file.c	2005-03-23 11:26:23.000000000 +0100
+++ mywine/dlls/kernel/tests/file.c	2005-03-31 16:59:27.000000000 +0200
@@ -571,9 +571,11 @@ static void test_CopyFileA(void)
        "WriteFile error %ld\n", GetLastError());
     ok(GetFileSize(hfile, NULL) == sizeof(prefix), "source file has wrong size\n");
     /* get the file time and change it to prove the difference */
-    ok(GetFileTime(hfile, NULL, NULL, &ft1), "GetFileTime error %ld\n", GetLastError());
+    ret = GetFileTime(hfile, NULL, NULL, &ft1);
+    ok( ret, "GetFileTime error %ld\n", GetLastError());
     ft1.dwLowDateTime -= 600000000; /* 60 second */
-    ok(SetFileTime(hfile, NULL, NULL, &ft1), "SetFileTime error %ld\n", GetLastError());
+    ret = SetFileTime(hfile, NULL, NULL, &ft1);
+    ok( ret, "SetFileTime error %ld\n", GetLastError());
     GetFileTime(hfile, NULL, NULL, &ft1);  /* get the actual time back */
     CloseHandle(hfile);
 
@@ -595,7 +597,8 @@ static void test_CopyFileA(void)
     ok(ret == sizeof(prefix), "destination file has wrong size %ld\n", ret);
 
     /* make sure that destination has the same filetime */
-    ok(ret = GetFileTime(hfile, NULL, NULL, &ft2), "GetFileTime error %ld\n", GetLastError());
+    ret = GetFileTime(hfile, NULL, NULL, &ft2);
+    ok( ret, "GetFileTime error %ld\n", GetLastError());
     ok(CompareFileTime(&ft1, &ft2) == 0, "destination file has wrong filetime\n");
 
     SetLastError(0xdeadbeef);


More information about the wine-patches mailing list