mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
ntdll/tests: Use the available ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8d876e740e
commit
3400da025e
10 changed files with 33 additions and 35 deletions
|
@ -74,8 +74,8 @@ static struct testfile_s {
|
|||
{ 0, 0, FILE_ATTRIBUTE_DIRECTORY, {'.'}, ". directory" },
|
||||
{ 0, 0, FILE_ATTRIBUTE_DIRECTORY, {'.','.'}, ".. directory" }
|
||||
};
|
||||
static const int test_dir_count = sizeof(testfiles) / sizeof(testfiles[0]);
|
||||
static const int max_test_dir_size = sizeof(testfiles) / sizeof(testfiles[0]) + 5; /* size of above plus some for .. etc */
|
||||
static const int test_dir_count = ARRAY_SIZE(testfiles);
|
||||
static const int max_test_dir_size = ARRAY_SIZE(testfiles) + 5; /* size of above plus some for .. etc */
|
||||
|
||||
static const WCHAR dummyW[] = {'d','u','m','m','y',0};
|
||||
static const WCHAR dotW[] = {'.',0};
|
||||
|
|
|
@ -643,7 +643,7 @@ static void test_prot_fault(void)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(exceptions)/sizeof(exceptions[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(exceptions); i++)
|
||||
{
|
||||
if (is_wow64 && exceptions[i].wow64_broken && !strcmp( winetest_platform, "windows" ))
|
||||
{
|
||||
|
@ -1734,7 +1734,7 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test )
|
|||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
static const UINT nb_regs = sizeof(test->results[i].regs) / sizeof(test->results[i].regs[0]);
|
||||
static const UINT nb_regs = ARRAY_SIZE(test->results[i].regs);
|
||||
|
||||
for (k = 0; k < nb_regs; k++)
|
||||
{
|
||||
|
@ -1888,14 +1888,12 @@ static void test_virtual_unwind(void)
|
|||
|
||||
static const struct unwind_test tests[] =
|
||||
{
|
||||
{ function_0, sizeof(function_0), unwind_info_0,
|
||||
results_0, sizeof(results_0)/sizeof(results_0[0]) },
|
||||
{ function_1, sizeof(function_1), unwind_info_1,
|
||||
results_1, sizeof(results_1)/sizeof(results_1[0]) }
|
||||
{ function_0, sizeof(function_0), unwind_info_0, results_0, ARRAY_SIZE(results_0) },
|
||||
{ function_1, sizeof(function_1), unwind_info_1, results_1, ARRAY_SIZE(results_1) }
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
||||
call_virtual_unwind( i, &tests[i] );
|
||||
}
|
||||
|
||||
|
@ -2429,7 +2427,7 @@ static void test_prot_fault(void)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(exceptions)/sizeof(exceptions[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(exceptions); i++)
|
||||
{
|
||||
got_exception = 0;
|
||||
run_exception_test(handler, &exceptions[i], &exceptions[i].code,
|
||||
|
@ -2567,7 +2565,7 @@ static void test_debug_registers(void)
|
|||
HANDLE thread;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
||||
{
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
|
||||
|
|
|
@ -563,7 +563,7 @@ static void delete_file_test(void)
|
|||
ok(0, "couldn't get temp dir\n");
|
||||
return;
|
||||
}
|
||||
if (ret + sizeof(testdirW)/sizeof(WCHAR)-1 + sizeof(subdirW)/sizeof(WCHAR)-1 >= MAX_PATH)
|
||||
if (ret + ARRAY_SIZE(testdirW)-1 + ARRAY_SIZE(subdirW)-1 >= MAX_PATH)
|
||||
{
|
||||
ok(0, "MAX_PATH exceeded in constructing paths\n");
|
||||
return;
|
||||
|
@ -3379,7 +3379,7 @@ static void test_NtCreateFile(void)
|
|||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
|
||||
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(td); i++)
|
||||
{
|
||||
status = pNtCreateFile(&handle, GENERIC_READ, &attr, &io, NULL,
|
||||
td[i].attrib_in, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
|
|
|
@ -1613,7 +1613,7 @@ static void test_query_process_debug_flags(int argc, char **argv)
|
|||
ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
|
||||
ok(debug_flags == TRUE, "Expected flag TRUE, got %x.\n", debug_flags);
|
||||
|
||||
for (i = 0; i < sizeof(test_flags)/sizeof(test_flags[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(test_flags); i++)
|
||||
{
|
||||
DWORD expected_flags = !(test_flags[i] & DEBUG_ONLY_THIS_PROCESS);
|
||||
sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
|
||||
|
|
|
@ -650,7 +650,7 @@ static void test_name_limits(void)
|
|||
|
||||
/* named pipes */
|
||||
memcpy( str.Buffer, pipeW, sizeof(pipeW) );
|
||||
for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(pipeW)/sizeof(WCHAR)] = 'a';
|
||||
for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + ARRAY_SIZE(pipeW)] = 'a';
|
||||
str.Length = 0;
|
||||
attr.RootDirectory = 0;
|
||||
attr.Attributes = OBJ_CASE_INSENSITIVE;
|
||||
|
@ -703,7 +703,7 @@ static void test_name_limits(void)
|
|||
|
||||
/* mailslots */
|
||||
memcpy( str.Buffer, mailslotW, sizeof(mailslotW) );
|
||||
for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(mailslotW)/sizeof(WCHAR)] = 'a';
|
||||
for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + ARRAY_SIZE(mailslotW)] = 'a';
|
||||
str.Length = 0;
|
||||
status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
|
||||
ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
|
||||
|
@ -744,7 +744,7 @@ static void test_name_limits(void)
|
|||
|
||||
/* registry keys */
|
||||
memcpy( str.Buffer, registryW, sizeof(registryW) );
|
||||
for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(registryW)/sizeof(WCHAR)] = 'a';
|
||||
for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + ARRAY_SIZE(registryW)] = 'a';
|
||||
str.Length = 0;
|
||||
status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
|
||||
todo_wine
|
||||
|
|
|
@ -230,8 +230,8 @@ static void test_create(void)
|
|||
static const DWORD sharing[] = { FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE };
|
||||
static const DWORD pipe_config[]= { 1, 0, 2 };
|
||||
|
||||
for (j = 0; j < sizeof(sharing) / sizeof(DWORD); j++) {
|
||||
for (k = 0; k < sizeof(access) / sizeof(DWORD); k++) {
|
||||
for (j = 0; j < ARRAY_SIZE(sharing); j++) {
|
||||
for (k = 0; k < ARRAY_SIZE(access); k++) {
|
||||
HANDLE hclient;
|
||||
BOOL should_succeed = TRUE;
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ static void test_RtlRandom(void)
|
|||
}
|
||||
|
||||
seed = 0;
|
||||
for (i = 0; i < sizeof(res) / sizeof(res[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(res); i++)
|
||||
{
|
||||
res[i] = pRtlRandom(&seed);
|
||||
ok(seed != res[i], "%i: seed is same as res %x\n", i, seed);
|
||||
|
@ -1226,7 +1226,7 @@ static void test_RtlIpv4StringToAddress(void)
|
|||
{ "::1", STATUS_INVALID_PARAMETER, 0, { -1 } },
|
||||
{ ":1", STATUS_INVALID_PARAMETER, 0, { -1 } },
|
||||
};
|
||||
const int testcount = sizeof(tests) / sizeof(tests[0]);
|
||||
const int testcount = ARRAY_SIZE(tests);
|
||||
int i;
|
||||
|
||||
if (!pRtlIpv4StringToAddressA)
|
||||
|
@ -1787,7 +1787,7 @@ static void test_RtlDecompressBuffer(void)
|
|||
ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
|
||||
|
||||
/* regular tests for RtlDecompressBuffer */
|
||||
for (i = 0; i < sizeof(test_lznt) / sizeof(test_lznt[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(test_lznt); i++)
|
||||
{
|
||||
trace("Running test %d (compressed_size=%u, uncompressed_size=%u, status=0x%08x)\n",
|
||||
i, test_lznt[i].compressed_size, test_lznt[i].uncompressed_size, test_lznt[i].status);
|
||||
|
|
|
@ -1769,7 +1769,7 @@ static void test_RtlIsTextUnicode(void)
|
|||
|
||||
be_unicode = HeapAlloc(GetProcessHeap(), 0, sizeof(unicode) + sizeof(WCHAR));
|
||||
be_unicode[0] = 0xfffe;
|
||||
for (i = 0; i < sizeof(unicode)/sizeof(unicode[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(unicode); i++)
|
||||
{
|
||||
be_unicode[i + 1] = (unicode[i] >> 8) | ((unicode[i] & 0xff) << 8);
|
||||
}
|
||||
|
@ -1791,7 +1791,7 @@ static void test_RtlIsTextUnicode(void)
|
|||
be_unicode_no_controls = HeapAlloc(GetProcessHeap(), 0, sizeof(unicode) + sizeof(WCHAR));
|
||||
ok(be_unicode_no_controls != NULL, "Expected HeapAlloc to succeed.\n");
|
||||
be_unicode_no_controls[0] = 0xfffe;
|
||||
for (i = 0; i < sizeof(unicode_no_controls)/sizeof(unicode_no_controls[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(unicode_no_controls); i++)
|
||||
be_unicode_no_controls[i + 1] = (unicode_no_controls[i] >> 8) | ((unicode_no_controls[i] & 0xff) << 8);
|
||||
|
||||
|
||||
|
@ -2093,7 +2093,7 @@ static void test_RtlUnicodeToUTF8N(void)
|
|||
const WCHAR special_string[] = { 'X',0x80,0xd800,0 };
|
||||
const unsigned char special_expected[] = { 'X',0xc2,0x80,0xef,0xbf,0xbd,0 };
|
||||
unsigned int input_len;
|
||||
const unsigned int test_count = sizeof(unicode_to_utf8) / sizeof(unicode_to_utf8[0]);
|
||||
const unsigned int test_count = ARRAY_SIZE(unicode_to_utf8);
|
||||
unsigned int i;
|
||||
|
||||
if (!pRtlUnicodeToUTF8N)
|
||||
|
@ -2374,7 +2374,7 @@ static void unicode_expect_(const WCHAR *out_string, ULONG buflen, ULONG out_cha
|
|||
ok_(__FILE__, line)(buffer[i] == out_string[i],
|
||||
"buffer[%d] = 0x%x, expected 0x%x\n",
|
||||
i, buffer[i], out_string[i]);
|
||||
for (; i < sizeof(buffer) / sizeof(WCHAR); i++)
|
||||
for (; i < ARRAY_SIZE(buffer); i++)
|
||||
ok_(__FILE__, line)(buffer[i] == 0x5555,
|
||||
"buffer[%d] = 0x%x, expected 0x5555\n",
|
||||
i, buffer[i]);
|
||||
|
@ -2396,7 +2396,7 @@ static void test_RtlUTF8ToUnicodeN(void)
|
|||
const char special_string[] = { 'X',0xc2,0x80,0xF0,0x90,0x80,0x80,0 };
|
||||
const WCHAR special_expected[] = { 'X',0x80,0xd800,0xdc00,0 };
|
||||
unsigned int input_len;
|
||||
const unsigned int test_count = sizeof(utf8_to_unicode) / sizeof(utf8_to_unicode[0]);
|
||||
const unsigned int test_count = ARRAY_SIZE(utf8_to_unicode);
|
||||
unsigned int i;
|
||||
|
||||
if (!pRtlUTF8ToUnicodeN)
|
||||
|
|
|
@ -1258,7 +1258,7 @@ static void test_bsearch(void)
|
|||
int *x, l, i, j;
|
||||
|
||||
/* just try all array sizes */
|
||||
for (j=1;j<sizeof(arr)/sizeof(arr[0]);j++) {
|
||||
for (j=1;j<ARRAY_SIZE(arr);j++) {
|
||||
for (i=0;i<j;i++) {
|
||||
l = arr[i];
|
||||
x = p_bsearch (&l, arr, j, sizeof(arr[0]), intcomparefunc);
|
||||
|
|
|
@ -1824,7 +1824,7 @@ static void test_tp_multi_wait(void)
|
|||
environment.Pool = pool;
|
||||
|
||||
/* create semaphores and corresponding wait objects */
|
||||
for (i = 0; i < sizeof(semaphores)/sizeof(semaphores[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(semaphores); i++)
|
||||
{
|
||||
semaphores[i] = CreateSemaphoreW(NULL, 0, 1, NULL);
|
||||
ok(semaphores[i] != NULL, "failed to create semaphore %i\n", i);
|
||||
|
@ -1838,7 +1838,7 @@ static void test_tp_multi_wait(void)
|
|||
}
|
||||
|
||||
/* release all semaphores and wait for callback */
|
||||
for (i = 0; i < sizeof(semaphores)/sizeof(semaphores[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(semaphores); i++)
|
||||
{
|
||||
multi_wait_info.result = 0;
|
||||
ReleaseSemaphore(semaphores[i], 1, NULL);
|
||||
|
@ -1851,7 +1851,7 @@ static void test_tp_multi_wait(void)
|
|||
}
|
||||
|
||||
/* repeat the same test in reverse order */
|
||||
for (i = sizeof(semaphores)/sizeof(semaphores[0]) - 1; i >= 0; i--)
|
||||
for (i = ARRAY_SIZE(semaphores) - 1; i >= 0; i--)
|
||||
{
|
||||
multi_wait_info.result = 0;
|
||||
ReleaseSemaphore(semaphores[i], 1, NULL);
|
||||
|
@ -1865,13 +1865,13 @@ static void test_tp_multi_wait(void)
|
|||
|
||||
/* test timeout of wait objects */
|
||||
multi_wait_info.result = 0;
|
||||
for (i = 0; i < sizeof(semaphores)/sizeof(semaphores[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(semaphores); i++)
|
||||
{
|
||||
when.QuadPart = (ULONGLONG)50 * -10000;
|
||||
pTpSetWait(waits[i], semaphores[i], &when);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(semaphores)/sizeof(semaphores[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(semaphores); i++)
|
||||
{
|
||||
result = WaitForSingleObject(semaphore, 150);
|
||||
ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
|
||||
|
@ -1880,14 +1880,14 @@ static void test_tp_multi_wait(void)
|
|||
ok(multi_wait_info.result >> 16, "expected multi_wait_info.result >> 16 != 0\n");
|
||||
|
||||
/* destroy the wait objects and semaphores while waiting */
|
||||
for (i = 0; i < sizeof(semaphores)/sizeof(semaphores[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(semaphores); i++)
|
||||
{
|
||||
pTpSetWait(waits[i], semaphores[i], NULL);
|
||||
}
|
||||
|
||||
Sleep(50);
|
||||
|
||||
for (i = 0; i < sizeof(semaphores)/sizeof(semaphores[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(semaphores); i++)
|
||||
{
|
||||
pTpReleaseWait(waits[i]);
|
||||
NtClose(semaphores[i]);
|
||||
|
|
Loading…
Reference in a new issue