Updated eventfd_synchronization patchset

Warning fixes.
This commit is contained in:
Alistair Leslie-Hughes 2022-03-14 14:39:37 +11:00
parent 74300a69fb
commit 508669b7f7
4 changed files with 89 additions and 89 deletions

View File

@ -29,97 +29,97 @@ index b158ac905fd..ad6ab1adc96 100644
CloseHandle( handle );
+
+ handle = CreateSemaphoreA( NULL, 0, 5, NULL );
+ ok(!!handle, "CreateSemaphore failed: %u\n", GetLastError());
+ ok(!!handle, "CreateSemaphore failed: %lu\n", GetLastError());
+
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ret = ReleaseSemaphore( handle, 1, &prev );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(prev == 0, "got prev %d\n", prev);
+ ok(ret, "got error %lu\n", GetLastError());
+ ok(prev == 0, "got prev %ld\n", prev);
+
+ ret = ReleaseSemaphore( handle, 1, &prev );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(prev == 1, "got prev %d\n", prev);
+ ok(ret, "got error %lu\n", GetLastError());
+ ok(prev == 1, "got prev %ld\n", prev);
+
+ ret = ReleaseSemaphore( handle, 5, &prev );
+ ok(!ret, "got %d\n", ret);
+ ok(GetLastError() == ERROR_TOO_MANY_POSTS, "got error %u\n", GetLastError());
+ ok(prev == 1, "got prev %d\n", prev);
+ ok(!ret, "got %ld\n", ret);
+ ok(GetLastError() == ERROR_TOO_MANY_POSTS, "got error %lu\n", GetLastError());
+ ok(prev == 1, "got prev %ld\n", prev);
+
+ ret = ReleaseSemaphore( handle, 2, &prev );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(prev == 2, "got prev %d\n", prev);
+ ok(ret, "got error %lu\n", GetLastError());
+ ok(prev == 2, "got prev %ld\n", prev);
+
+ ret = ReleaseSemaphore( handle, 1, &prev );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(prev == 4, "got prev %d\n", prev);
+ ok(ret, "got error %lu\n", GetLastError());
+ ok(prev == 4, "got prev %ld\n", prev);
+
+ for (i = 0; i < 5; i++)
+ {
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+ }
+
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ handle2 = CreateSemaphoreA( NULL, 3, 5, NULL );
+ ok(!!handle2, "CreateSemaphore failed: %u\n", GetLastError());
+ ok(!!handle2, "CreateSemaphore failed: %lu\n", GetLastError());
+
+ ret = ReleaseSemaphore( handle2, 1, &prev );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(prev == 3, "got prev %d\n", prev);
+ ok(ret, "got error %lu\n", GetLastError());
+ ok(prev == 3, "got prev %ld\n", prev);
+
+ for (i = 0; i < 4; i++)
+ {
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+ }
+
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ handles[0] = handle;
+ handles[1] = handle2;
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ReleaseSemaphore( handle, 1, NULL );
+ ReleaseSemaphore( handle2, 1, NULL );
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 1, "got %u\n", ret);
+ ok(ret == 1, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ReleaseSemaphore( handle, 1, NULL );
+ ReleaseSemaphore( handle2, 1, NULL );
+
+ ret = WaitForMultipleObjects( 2, handles, TRUE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ReleaseSemaphore( handle, 1, NULL );
+
+ ret = WaitForMultipleObjects( 2, handles, TRUE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = CloseHandle( handle );
+ ok(ret, "got error %u\n", ret);
+ ok(ret, "got error %lu\n", ret);
+
+ ret = CloseHandle( handle2 );
+ ok(ret, "got error %u\n", ret);
+ ok(ret, "got error %lu\n", ret);
}
static void test_waitable_timer(void)

View File

@ -32,100 +32,100 @@ index ad6ab1adc96..95f51f54b83 100644
CloseHandle( handle );
+
+ handle = CreateEventA( NULL, TRUE, FALSE, NULL );
+ ok(!!handle, "got error %u\n", GetLastError());
+ ok(!!handle, "got error %lu\n", GetLastError());
+
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ret = SetEvent( handle );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = SetEvent( handle );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ for (i = 0; i < 100; i++)
+ {
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+ }
+
+ ret = ResetEvent( handle );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = ResetEvent( handle );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = WaitForSingleObject( handle, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ handle2 = CreateEventA( NULL, FALSE, TRUE, NULL );
+ ok(!!handle2, "got error %u\n", GetLastError());
+ ok(!!handle2, "got error %lu\n", GetLastError());
+
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ret = SetEvent( handle2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = SetEvent( handle2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = ResetEvent( handle2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = ResetEvent( handle2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ handles[0] = handle;
+ handles[1] = handle2;
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ SetEvent( handle );
+ SetEvent( handle2 );
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ResetEvent( handle );
+ SetEvent( handle2 );
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 1, "got %u\n", ret);
+ ok(ret == 1, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ SetEvent( handle );
+ SetEvent( handle2 );
+
+ ret = WaitForMultipleObjects( 2, handles, TRUE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, TRUE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ SetEvent( handle2 );
+ ResetEvent( handle );
+
+ ret = WaitForMultipleObjects( 2, handles, TRUE, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ ret = WaitForSingleObject( handle2, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ handles[0] = handle2;
+ handles[1] = handle;
@ -133,19 +133,19 @@ index ad6ab1adc96..95f51f54b83 100644
+ SetEvent( handle2 );
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 1, "got %u\n", ret);
+ ok(ret == 1, "got %lu\n", ret);
+
+ ret = WaitForMultipleObjects( 2, handles, FALSE, 0 );
+ ok(ret == 1, "got %u\n", ret);
+ ok(ret == 1, "got %lu\n", ret);
+
+ ret = CloseHandle( handle );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = CloseHandle( handle2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
}
static void test_semaphore(void)

View File

@ -23,7 +23,7 @@ index ea54cb069df..790b7bfe797 100644
+ DWORD ret;
+
+ ret = WaitForSingleObject( mutex, 0 );
+ ok(ret == expect, "expected %u, got %u\n", expect, ret);
+ ok(ret == expect, "expected %lu, got %lu\n", expect, ret);
+
+ if (!ret) ReleaseMutex( mutex );
+ return 0;
@ -41,11 +41,11 @@ index ea54cb069df..790b7bfe797 100644
CloseHandle(hCreated);
+
+ mutex = CreateMutexA( NULL, FALSE, NULL );
+ ok(!!mutex, "got error %u\n", GetLastError());
+ ok(!!mutex, "got error %lu\n", GetLastError());
+
+ ret = ReleaseMutex( mutex );
+ ok(!ret, "got %d\n", ret);
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %u\n", GetLastError());
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %lu\n", GetLastError());
+
+ for (i = 0; i < 100; i++)
+ {
@ -56,12 +56,12 @@ index ea54cb069df..790b7bfe797 100644
+ for (i = 0; i < 100; i++)
+ {
+ ret = ReleaseMutex( mutex );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+ }
+
+ ret = ReleaseMutex( mutex );
+ ok(!ret, "got %d\n", ret);
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %u\n", GetLastError());
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %lu\n", GetLastError());
+
+ thread = CreateThread( NULL, 0, mutex_thread, (void *)0, 0, NULL );
+ ret = WaitForSingleObject( thread, 2000 );
@ -74,21 +74,21 @@ index ea54cb069df..790b7bfe797 100644
+ ok(ret == 0, "wait failed: %u\n", ret);
+
+ ret = ReleaseMutex( mutex );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ thread = CreateThread( NULL, 0, mutex_thread, (void *)0, 0, NULL );
+ ret = WaitForSingleObject( thread, 2000 );
+ ok(ret == 0, "wait failed: %u\n", ret);
+
+ mutex2 = CreateMutexA( NULL, TRUE, NULL );
+ ok(!!mutex2, "got error %u\n", GetLastError());
+ ok(!!mutex2, "got error %lu\n", GetLastError());
+
+ ret = ReleaseMutex( mutex2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = ReleaseMutex( mutex2 );
+ ok(!ret, "got %d\n", ret);
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %u\n", GetLastError());
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %lu\n", GetLastError());
+
+ mutices[0] = mutex;
+ mutices[1] = mutex2;
@ -97,26 +97,26 @@ index ea54cb069df..790b7bfe797 100644
+ ok(ret == 0, "got %u\n", ret);
+
+ ret = ReleaseMutex( mutex );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = ReleaseMutex( mutex2 );
+ ok(!ret, "got %d\n", ret);
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %u\n", GetLastError());
+ ok(GetLastError() == ERROR_NOT_OWNER, "got error %lu\n", GetLastError());
+
+ ret = WaitForMultipleObjects( 2, mutices, TRUE, 0 );
+ ok(ret == 0, "got %u\n", ret);
+
+ ret = ReleaseMutex( mutex );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = ReleaseMutex( mutex2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = CloseHandle( mutex );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
+ ret = CloseHandle( mutex2 );
+ ok(ret, "got error %u\n", GetLastError());
+ ok(ret, "got error %lu\n", GetLastError());
+
}

View File

@ -40,33 +40,33 @@ index 4685b7bec06..117edf12fb6 100644
ok(status == STATUS_TIMEOUT, "expected STATUS_TIMEOUT, got %08lx\n", status);
+ ret = WaitForSingleObject( signaled, 0 );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ ret = WaitForSingleObject( nonsignaled, 0 );
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+
+ /* test that a timed wait actually does wait */
+ now = GetTickCount();
+ ret = WaitForSingleObject( nonsignaled, 100 );
+ then = GetTickCount();
+ ok(ret == WAIT_TIMEOUT, "got %u\n", ret);
+ ok(abs((then - now) - 100) < 5, "got %u ms\n", then - now);
+ ok(ret == WAIT_TIMEOUT, "got %lu\n", ret);
+ ok(abs((then - now) - 100) < 5, "got %lu ms\n", then - now);
+
+ now = GetTickCount();
+ ret = WaitForSingleObject( signaled, 100 );
+ then = GetTickCount();
+ ok(ret == 0, "got %u\n", ret);
+ ok(abs(then - now) < 5, "got %u ms\n", then - now);
+ ok(ret == 0, "got %lu\n", ret);
+ ok(abs(then - now) < 5, "got %lu ms\n", then - now);
+
+ ret = WaitForSingleObject( signaled, INFINITE );
+ ok(ret == 0, "got %u\n", ret);
+ ok(ret == 0, "got %lu\n", ret);
+
+ /* test NT timeouts */
+ pNtQuerySystemTime( &ntnow );
+ timeout.QuadPart = ntnow.QuadPart + 100 * 10000;
+ status = pNtWaitForSingleObject( nonsignaled, FALSE, &timeout );
+ pNtQuerySystemTime( &ntthen );
+ ok(status == STATUS_TIMEOUT, "got %#x\n", status);
+ ok(status == STATUS_TIMEOUT, "got %#lx\n", status);
+ ok(abs(((ntthen.QuadPart - ntnow.QuadPart) / 10000) - 100) < 5, "got %s ns\n",
+ wine_dbgstr_longlong((ntthen.QuadPart - ntnow.QuadPart) * 100));
+
@ -74,22 +74,22 @@ index 4685b7bec06..117edf12fb6 100644
+ timeout.QuadPart = -100 * 10000;
+ status = pNtWaitForSingleObject( nonsignaled, FALSE, &timeout );
+ pNtQuerySystemTime( &ntthen );
+ ok(status == STATUS_TIMEOUT, "got %#x\n", status);
+ ok(status == STATUS_TIMEOUT, "got %#lx\n", status);
+ ok(abs(((ntthen.QuadPart - ntnow.QuadPart) / 10000) - 100) < 5, "got %s ns\n",
+ wine_dbgstr_longlong((ntthen.QuadPart - ntnow.QuadPart) * 100));
+
+ status = pNtWaitForSingleObject( signaled, FALSE, NULL );
+ ok(status == 0, "got %#x\n", status);
+ ok(status == 0, "got %#lx\n", status);
+
+ timeout.QuadPart = TIMEOUT_INFINITE;
+ status = pNtWaitForSingleObject( signaled, FALSE, &timeout );
+ ok(status == 0, "got %#x\n", status);
+ ok(status == 0, "got %#lx\n", status);
+
+ pNtQuerySystemTime( &ntnow );
+ timeout.QuadPart = ntnow.QuadPart;
+ status = pNtWaitForSingleObject( nonsignaled, FALSE, &timeout );
+ pNtQuerySystemTime( &ntthen );
+ ok(status == STATUS_TIMEOUT, "got %#x\n", status);
+ ok(status == STATUS_TIMEOUT, "got %#lx\n", status);
+ ok(abs((ntthen.QuadPart - ntnow.QuadPart) / 10000) < 5, "got %s ns\n",
+ wine_dbgstr_longlong((ntthen.QuadPart - ntnow.QuadPart) * 100));
+
@ -97,7 +97,7 @@ index 4685b7bec06..117edf12fb6 100644
+ timeout.QuadPart = ntnow.QuadPart - 100 * 10000;
+ status = pNtWaitForSingleObject( nonsignaled, FALSE, &timeout );
+ pNtQuerySystemTime( &ntthen );
+ ok(status == STATUS_TIMEOUT, "got %#x\n", status);
+ ok(status == STATUS_TIMEOUT, "got %#lx\n", status);
+ ok(abs((ntthen.QuadPart - ntnow.QuadPart) / 10000) < 5, "got %s ns\n",
+ wine_dbgstr_longlong((ntthen.QuadPart - ntnow.QuadPart) * 100));
+