Commit 80be3a46 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

kernel32/tests: Use the available ARRAY_SIZE() macro.

parent 37e22ebb
...@@ -533,7 +533,7 @@ static int strcmp_aw(LPCWSTR strw, const char *stra) ...@@ -533,7 +533,7 @@ static int strcmp_aw(LPCWSTR strw, const char *stra)
WCHAR buf[1024]; WCHAR buf[1024];
if (!stra) return 1; if (!stra) return 1;
MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf); return lstrcmpW(strw, buf);
} }
...@@ -550,7 +550,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest, int ...@@ -550,7 +550,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest, int
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH ); MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
GetFullPathNameW(path, sizeof(manifest_path)/sizeof(WCHAR), manifest_path, NULL); GetFullPathNameW(path, ARRAY_SIZE(manifest_path), manifest_path, NULL);
if (manifest_len == -1) if (manifest_len == -1)
manifest_len = strlen(manifest); manifest_len = strlen(manifest);
...@@ -566,7 +566,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest, int ...@@ -566,7 +566,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest, int
if (depmanifest) if (depmanifest)
{ {
MultiByteToWideChar( CP_ACP, 0, depfile, -1, path, MAX_PATH ); MultiByteToWideChar( CP_ACP, 0, depfile, -1, path, MAX_PATH );
GetFullPathNameW(path, sizeof(depmanifest_path)/sizeof(WCHAR), depmanifest_path, NULL); GetFullPathNameW(path, ARRAY_SIZE(depmanifest_path), depmanifest_path, NULL);
file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL); FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError()); ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
...@@ -2558,7 +2558,7 @@ static void init_paths(void) ...@@ -2558,7 +2558,7 @@ static void init_paths(void)
static const WCHAR backslash[] = {'\\',0}; static const WCHAR backslash[] = {'\\',0};
static const WCHAR subdir[] = {'T','e','s','t','S','u','b','d','i','r','\\',0}; static const WCHAR subdir[] = {'T','e','s','t','S','u','b','d','i','r','\\',0};
GetModuleFileNameW(NULL, exe_path, sizeof(exe_path)/sizeof(WCHAR)); GetModuleFileNameW(NULL, exe_path, ARRAY_SIZE(exe_path));
lstrcpyW(app_dir, exe_path); lstrcpyW(app_dir, exe_path);
for(ptr=app_dir+lstrlenW(app_dir); *ptr != '\\' && *ptr != '/'; ptr--); for(ptr=app_dir+lstrlenW(app_dir); *ptr != '\\' && *ptr != '/'; ptr--);
ptr[1] = 0; ptr[1] = 0;
...@@ -2570,7 +2570,7 @@ static void init_paths(void) ...@@ -2570,7 +2570,7 @@ static void init_paths(void)
lstrcpyW(work_dir_subdir, work_dir); lstrcpyW(work_dir_subdir, work_dir);
lstrcatW(work_dir_subdir, subdir); lstrcatW(work_dir_subdir, subdir);
GetModuleFileNameW(NULL, app_manifest_path, sizeof(app_manifest_path)/sizeof(WCHAR)); GetModuleFileNameW(NULL, app_manifest_path, ARRAY_SIZE(app_manifest_path));
lstrcpyW(app_manifest_path+lstrlenW(app_manifest_path), dot_manifest); lstrcpyW(app_manifest_path+lstrlenW(app_manifest_path), dot_manifest);
} }
...@@ -2580,7 +2580,7 @@ static void write_manifest(const char *filename, const char *manifest) ...@@ -2580,7 +2580,7 @@ static void write_manifest(const char *filename, const char *manifest)
DWORD size; DWORD size;
CHAR path[MAX_PATH]; CHAR path[MAX_PATH];
GetTempPathA(sizeof(path)/sizeof(CHAR), path); GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, filename); strcat(path, filename);
file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
...@@ -2593,7 +2593,7 @@ static void delete_manifest_file(const char *filename) ...@@ -2593,7 +2593,7 @@ static void delete_manifest_file(const char *filename)
{ {
CHAR path[MAX_PATH]; CHAR path[MAX_PATH];
GetTempPathA(sizeof(path)/sizeof(CHAR), path); GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, filename); strcat(path, filename);
DeleteFileA(path); DeleteFileA(path);
} }
...@@ -2604,7 +2604,7 @@ static void test_CreateActCtx(void) ...@@ -2604,7 +2604,7 @@ static void test_CreateActCtx(void)
ACTCTXA actctx; ACTCTXA actctx;
HANDLE handle; HANDLE handle;
GetTempPathA(sizeof(path)/sizeof(CHAR), path); GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, "main_wndcls.manifest"); strcat(path, "main_wndcls.manifest");
write_manifest("testdep1.manifest", manifest_wndcls1); write_manifest("testdep1.manifest", manifest_wndcls1);
...@@ -2621,7 +2621,7 @@ static void test_CreateActCtx(void) ...@@ -2621,7 +2621,7 @@ static void test_CreateActCtx(void)
pReleaseActCtx(handle); pReleaseActCtx(handle);
/* with specified directory, that doesn't contain dependent assembly */ /* with specified directory, that doesn't contain dependent assembly */
GetWindowsDirectoryA(dir, sizeof(dir)/sizeof(CHAR)); GetWindowsDirectoryA(dir, ARRAY_SIZE(dir));
memset(&actctx, 0, sizeof(ACTCTXA)); memset(&actctx, 0, sizeof(ACTCTXA));
actctx.cbSize = sizeof(ACTCTXA); actctx.cbSize = sizeof(ACTCTXA);
...@@ -2667,7 +2667,7 @@ todo_wine ...@@ -2667,7 +2667,7 @@ todo_wine
/* load manifest from lpAssemblyDirectory directory */ /* load manifest from lpAssemblyDirectory directory */
write_manifest("testdir.manifest", manifest1); write_manifest("testdir.manifest", manifest1);
GetTempPathA(sizeof(path)/sizeof(path[0]), path); GetTempPathA(ARRAY_SIZE(path), path);
SetCurrentDirectoryA(path); SetCurrentDirectoryA(path);
strcat(path, "assembly_dir"); strcat(path, "assembly_dir");
strcpy(dir, path); strcpy(dir, path);
...@@ -3048,14 +3048,14 @@ static void test_settings(void) ...@@ -3048,14 +3048,14 @@ static void test_settings(void)
ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwareW, buffer, 80, &size ); ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwareW, buffer, 80, &size );
ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() ); ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) ); ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
ok( size == sizeof(trueW)/sizeof(WCHAR), "wrong len %lu\n", size ); ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
size = 0xdead; size = 0xdead;
memset( buffer, 0xcc, sizeof(buffer) ); memset( buffer, 0xcc, sizeof(buffer) );
ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwareW, buffer, lstrlenW(trueW) + 1, &size ); ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwareW, buffer, lstrlenW(trueW) + 1, &size );
ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() ); ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) ); ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
ok( size == sizeof(trueW)/sizeof(WCHAR), "wrong len %lu\n", size ); ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
size = 0xdead; size = 0xdead;
memset( buffer, 0xcc, sizeof(buffer) ); memset( buffer, 0xcc, sizeof(buffer) );
...@@ -3087,7 +3087,7 @@ static void test_settings(void) ...@@ -3087,7 +3087,7 @@ static void test_settings(void)
if (ret) if (ret)
{ {
ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) ); ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
ok( size == sizeof(trueW)/sizeof(WCHAR), "wrong len %lu\n", size ); ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
} }
else ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) ); else ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
...@@ -3096,7 +3096,7 @@ static void test_settings(void) ...@@ -3096,7 +3096,7 @@ static void test_settings(void)
ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, lstrlenW(trueW), &size ); ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, lstrlenW(trueW), &size );
ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() ); ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) ); ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
ok( size == sizeof(trueW)/sizeof(WCHAR), "wrong len %lu\n", size ); ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
size = 0xdead; size = 0xdead;
memset( buffer, 0xcc, sizeof(buffer) ); memset( buffer, 0xcc, sizeof(buffer) );
...@@ -3104,7 +3104,7 @@ static void test_settings(void) ...@@ -3104,7 +3104,7 @@ static void test_settings(void)
ok( !ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() ); ok( !ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() ); ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) ); ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
ok( size == sizeof(trueW)/sizeof(WCHAR), "wrong len %lu\n", size ); ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
pReleaseActCtx(handle); pReleaseActCtx(handle);
create_manifest_file( "manifest_settings2.manifest", settings_manifest2, -1, NULL, NULL ); create_manifest_file( "manifest_settings2.manifest", settings_manifest2, -1, NULL, NULL );
......
...@@ -276,7 +276,7 @@ static void test_get_atom_name(void) ...@@ -276,7 +276,7 @@ static void test_get_atom_name(void)
do_initW(inW, "abcdefghij", 255); do_initW(inW, "abcdefghij", 255);
atom = GlobalAddAtomW(inW); atom = GlobalAddAtomW(inW);
ok(atom, "couldn't add atom for %s\n", in); ok(atom, "couldn't add atom for %s\n", in);
len = GlobalGetAtomNameW(atom, outW, sizeof(outW)/sizeof(outW[0])); len = GlobalGetAtomNameW(atom, outW, ARRAY_SIZE(outW));
ok(len == 255, "length mismatch (%u instead of 255)\n", len); ok(len == 255, "length mismatch (%u instead of 255)\n", len);
for (i = 0; i < 255; i++) for (i = 0; i < 255; i++)
{ {
...@@ -537,7 +537,7 @@ static void test_local_get_atom_name(void) ...@@ -537,7 +537,7 @@ static void test_local_get_atom_name(void)
do_initW(inW, "abcdefghij", 255); do_initW(inW, "abcdefghij", 255);
atom = AddAtomW(inW); atom = AddAtomW(inW);
ok(atom, "couldn't add atom for %s\n", in); ok(atom, "couldn't add atom for %s\n", in);
len = GetAtomNameW(atom, outW, sizeof(outW)/sizeof(outW[0])); len = GetAtomNameW(atom, outW, ARRAY_SIZE(outW));
ok(len == 255, "length mismatch (%u instead of 255)\n", len); ok(len == 255, "length mismatch (%u instead of 255)\n", len);
for (i = 0; i < 255; i++) for (i = 0; i < 255; i++)
{ {
......
...@@ -205,7 +205,7 @@ static void test_other_invalid_parameters(void) ...@@ -205,7 +205,7 @@ static void test_other_invalid_parameters(void)
char c_string[] = "Hello World"; char c_string[] = "Hello World";
size_t c_string_len = sizeof(c_string); size_t c_string_len = sizeof(c_string);
WCHAR w_string[] = {'H','e','l','l','o',' ','W','o','r','l','d',0}; WCHAR w_string[] = {'H','e','l','l','o',' ','W','o','r','l','d',0};
size_t w_string_len = sizeof(w_string) / sizeof(WCHAR); size_t w_string_len = ARRAY_SIZE(w_string);
BOOL used; BOOL used;
INT len; INT len;
...@@ -683,7 +683,7 @@ static void test_utf7_encoding(void) ...@@ -683,7 +683,7 @@ static void test_utf7_encoding(void)
i, expected_len, expected_len, output[expected_len]); i, expected_len, expected_len, output[expected_len]);
} }
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) for (i = 0; i < ARRAY_SIZE(tests); i++)
{ {
memset(output, '#', sizeof(output) - 1); memset(output, '#', sizeof(output) - 1);
output[sizeof(output) - 1] = 0; output[sizeof(output) - 1] = 0;
...@@ -746,12 +746,12 @@ static void test_utf7_decoding(void) ...@@ -746,12 +746,12 @@ static void test_utf7_decoding(void)
{ {
/* tests string conversion with srclen=-1 */ /* tests string conversion with srclen=-1 */
{ {
"+T2BZfQ-", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2BZfQ-", -1, output, ARRAY_SIZE(output) - 1,
{0x4F60,0x597D,0}, 3, 3 {0x4F60,0x597D,0}, 3, 3
}, },
/* tests string conversion with srclen=-2 */ /* tests string conversion with srclen=-2 */
{ {
"+T2BZfQ-", -2, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2BZfQ-", -2, output, ARRAY_SIZE(output) - 1,
{0x4F60,0x597D,0}, 3, 3 {0x4F60,0x597D,0}, 3, 3
}, },
/* tests string conversion with dstlen=strlen(expected_dst) */ /* tests string conversion with dstlen=strlen(expected_dst) */
...@@ -781,72 +781,72 @@ static void test_utf7_decoding(void) ...@@ -781,72 +781,72 @@ static void test_utf7_decoding(void)
}, },
/* tests ill-formed UTF-7: 6 bits, not enough for a byte pair */ /* tests ill-formed UTF-7: 6 bits, not enough for a byte pair */
{ {
"+T-+T-+T-hello", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "+T-+T-+T-hello", -1, output, ARRAY_SIZE(output) - 1,
{'h','e','l','l','o',0}, 6, 6 {'h','e','l','l','o',0}, 6, 6
}, },
/* tests ill-formed UTF-7: 12 bits, not enough for a byte pair */ /* tests ill-formed UTF-7: 12 bits, not enough for a byte pair */
{ {
"+T2-+T2-+T2-hello", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2-+T2-+T2-hello", -1, output, ARRAY_SIZE(output) - 1,
{'h','e','l','l','o',0}, 6, 6 {'h','e','l','l','o',0}, 6, 6
}, },
/* tests ill-formed UTF-7: 18 bits, not a multiple of 16 and the last bit is a 1 */ /* tests ill-formed UTF-7: 18 bits, not a multiple of 16 and the last bit is a 1 */
{ {
"+T2B-+T2B-+T2B-hello", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2B-+T2B-+T2B-hello", -1, output, ARRAY_SIZE(output) - 1,
{0x4F60,0x4F60,0x4F60,'h','e','l','l','o',0}, 9, 9 {0x4F60,0x4F60,0x4F60,'h','e','l','l','o',0}, 9, 9
}, },
/* tests ill-formed UTF-7: 24 bits, a multiple of 8 but not a multiple of 16 */ /* tests ill-formed UTF-7: 24 bits, a multiple of 8 but not a multiple of 16 */
{ {
"+T2BZ-+T2BZ-+T2BZ-hello", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2BZ-+T2BZ-+T2BZ-hello", -1, output, ARRAY_SIZE(output) - 1,
{0x4F60,0x4F60,0x4F60,'h','e','l','l','o',0}, 9, 9 {0x4F60,0x4F60,0x4F60,'h','e','l','l','o',0}, 9, 9
}, },
/* tests UTF-7 followed by characters that should be encoded but aren't */ /* tests UTF-7 followed by characters that should be encoded but aren't */
{ {
"+T2BZ-\x82\xFE", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2BZ-\x82\xFE", -1, output, ARRAY_SIZE(output) - 1,
{0x4F60,0x0082,0x00FE,0}, 4, 4 {0x4F60,0x0082,0x00FE,0}, 4, 4
}, },
/* tests srclen > strlen(src) */ /* tests srclen > strlen(src) */
{ {
"a\0b", 4, output, sizeof(output) / sizeof(WCHAR) - 1, "a\0b", 4, output, ARRAY_SIZE(output) - 1,
{'a',0,'b',0}, 4, 4 {'a',0,'b',0}, 4, 4
}, },
/* tests srclen < strlen(src) outside of a UTF-7 sequence */ /* tests srclen < strlen(src) outside of a UTF-7 sequence */
{ {
"hello", 2, output, sizeof(output) / sizeof(WCHAR) - 1, "hello", 2, output, ARRAY_SIZE(output) - 1,
{'h','e'}, 2, 2 {'h','e'}, 2, 2
}, },
/* tests srclen < strlen(src) inside of a UTF-7 sequence */ /* tests srclen < strlen(src) inside of a UTF-7 sequence */
{ {
"+T2BZfQ-", 4, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2BZfQ-", 4, output, ARRAY_SIZE(output) - 1,
{0x4F60}, 1, 1 {0x4F60}, 1, 1
}, },
/* tests srclen < strlen(src) right at the beginning of a UTF-7 sequence */ /* tests srclen < strlen(src) right at the beginning of a UTF-7 sequence */
{ {
"hi+T2A-", 3, output, sizeof(output) / sizeof(WCHAR) - 1, "hi+T2A-", 3, output, ARRAY_SIZE(output) - 1,
{'h','i'}, 2, 2 {'h','i'}, 2, 2
}, },
/* tests srclen < strlen(src) right at the end of a UTF-7 sequence */ /* tests srclen < strlen(src) right at the end of a UTF-7 sequence */
{ {
"+T2A-hi", 5, output, sizeof(output) / sizeof(WCHAR) - 1, "+T2A-hi", 5, output, ARRAY_SIZE(output) - 1,
{0x4F60}, 1, 1 {0x4F60}, 1, 1
}, },
/* tests srclen < strlen(src) at the beginning of an escaped + sign */ /* tests srclen < strlen(src) at the beginning of an escaped + sign */
{ {
"hi+-", 3, output, sizeof(output) / sizeof(WCHAR) - 1, "hi+-", 3, output, ARRAY_SIZE(output) - 1,
{'h','i'}, 2, 2 {'h','i'}, 2, 2
}, },
/* tests srclen < strlen(src) at the end of an escaped + sign */ /* tests srclen < strlen(src) at the end of an escaped + sign */
{ {
"+-hi", 2, output, sizeof(output) / sizeof(WCHAR) - 1, "+-hi", 2, output, ARRAY_SIZE(output) - 1,
{'+'}, 1, 1 {'+'}, 1, 1
}, },
/* tests len=0 but no error */ /* tests len=0 but no error */
{ {
"+", 1, output, sizeof(output) / sizeof(WCHAR) - 1, "+", 1, output, ARRAY_SIZE(output) - 1,
{}, 0, 0 {}, 0, 0
}, },
/* tests a single null char */ /* tests a single null char */
{ {
"", -1, output, sizeof(output) / sizeof(WCHAR) - 1, "", -1, output, ARRAY_SIZE(output) - 1,
{0}, 1, 1 {0}, 1, 1
}, },
/* tests a buffer that runs out while not decoding a UTF-7 sequence */ /* tests a buffer that runs out while not decoding a UTF-7 sequence */
...@@ -867,9 +867,9 @@ static void test_utf7_decoding(void) ...@@ -867,9 +867,9 @@ static void test_utf7_decoding(void)
sprintf(input, "+%c+AAA", i); sprintf(input, "+%c+AAA", i);
memset(output, 0x23, sizeof(output) - sizeof(WCHAR)); memset(output, 0x23, sizeof(output) - sizeof(WCHAR));
output[sizeof(output) / sizeof(WCHAR) - 1] = 0; output[ARRAY_SIZE(output) - 1] = 0;
len = MultiByteToWideChar(CP_UTF7, 0, input, 7, output, sizeof(output) / sizeof(WCHAR) - 1); len = MultiByteToWideChar(CP_UTF7, 0, input, 7, output, ARRAY_SIZE(output) - 1);
if (i == '-') if (i == '-')
{ {
...@@ -909,9 +909,9 @@ static void test_utf7_decoding(void) ...@@ -909,9 +909,9 @@ static void test_utf7_decoding(void)
sprintf(input, "+B%c+AAA", i); sprintf(input, "+B%c+AAA", i);
memset(output, 0x23, sizeof(output) - sizeof(WCHAR)); memset(output, 0x23, sizeof(output) - sizeof(WCHAR));
output[sizeof(output) / sizeof(WCHAR) - 1] = 0; output[ARRAY_SIZE(output) - 1] = 0;
len = MultiByteToWideChar(CP_UTF7, 0, input, 8, output, sizeof(output) / sizeof(WCHAR) - 1); len = MultiByteToWideChar(CP_UTF7, 0, input, 8, output, ARRAY_SIZE(output) - 1);
if (i == '-') if (i == '-')
{ {
...@@ -955,10 +955,10 @@ static void test_utf7_decoding(void) ...@@ -955,10 +955,10 @@ static void test_utf7_decoding(void)
i, wine_dbgstr_wn(expected, expected_len + 1), wine_dbgstr_wn(output, expected_len + 1)); i, wine_dbgstr_wn(expected, expected_len + 1), wine_dbgstr_wn(output, expected_len + 1));
} }
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) for (i = 0; i < ARRAY_SIZE(tests); i++)
{ {
memset(output, 0x23, sizeof(output) - sizeof(WCHAR)); memset(output, 0x23, sizeof(output) - sizeof(WCHAR));
output[sizeof(output) / sizeof(WCHAR) - 1] = 0; output[ARRAY_SIZE(output) - 1] = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
len = MultiByteToWideChar(CP_UTF7, 0, tests[i].src, tests[i].srclen, len = MultiByteToWideChar(CP_UTF7, 0, tests[i].src, tests[i].srclen,
...@@ -1004,7 +1004,7 @@ static void test_undefined_byte_char(void) ...@@ -1004,7 +1004,7 @@ static void test_undefined_byte_char(void)
}; };
INT i, ret; INT i, ret;
for (i = 0; i < (sizeof(testset) / sizeof(testset[0])); i++) { for (i = 0; i < ARRAY_SIZE(testset); i++) {
if (! IsValidCodePage(testset[i].codepage)) if (! IsValidCodePage(testset[i].codepage))
{ {
skip("Codepage %d not available\n", testset[i].codepage); skip("Codepage %d not available\n", testset[i].codepage);
...@@ -1106,7 +1106,7 @@ static void test_threadcp(void) ...@@ -1106,7 +1106,7 @@ static void test_threadcp(void)
last = GetThreadLocale(); last = GetThreadLocale();
acp = GetACP(); acp = GetACP();
for (i = 0; i < sizeof(lcids)/sizeof(lcids[0]); i++) for (i = 0; i < ARRAY_SIZE(lcids); i++)
{ {
SetThreadLocale(lcids[i].lcid); SetThreadLocale(lcids[i].lcid);
...@@ -1151,7 +1151,7 @@ static void test_threadcp(void) ...@@ -1151,7 +1151,7 @@ static void test_threadcp(void)
} }
/* IsDBCSLeadByteEx - locales without codepage */ /* IsDBCSLeadByteEx - locales without codepage */
for (i = 0; i < sizeof(isleads_nocp)/sizeof(isleads_nocp[0]); i++) for (i = 0; i < ARRAY_SIZE(isleads_nocp); i++)
{ {
SetThreadLocale(isleads_nocp[i].lcid); SetThreadLocale(isleads_nocp[i].lcid);
...@@ -1163,7 +1163,7 @@ static void test_threadcp(void) ...@@ -1163,7 +1163,7 @@ static void test_threadcp(void)
} }
/* IsDBCSLeadByteEx - locales with codepage */ /* IsDBCSLeadByteEx - locales with codepage */
for (i = 0; i < sizeof(isleads)/sizeof(isleads[0]); i++) for (i = 0; i < ARRAY_SIZE(isleads); i++)
{ {
SetThreadLocale(isleads[i].lcid); SetThreadLocale(isleads[i].lcid);
...@@ -1194,7 +1194,7 @@ static void test_dbcs_to_widechar(void) ...@@ -1194,7 +1194,7 @@ static void test_dbcs_to_widechar(void)
MB_COMPOSITE |MB_ERR_INVALID_CHARS|MB_USEGLYPHCHARS, MB_COMPOSITE |MB_ERR_INVALID_CHARS|MB_USEGLYPHCHARS,
}; };
for (i = 0; i < sizeof(flags)/sizeof(DWORD); ++i) for (i = 0; i < ARRAY_SIZE(flags); ++i)
{ {
memset(wbuf, 0xff, sizeof(wbuf)); memset(wbuf, 0xff, sizeof(wbuf));
count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 2, NULL, 0); count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 2, NULL, 0);
...@@ -1206,7 +1206,7 @@ static void test_dbcs_to_widechar(void) ...@@ -1206,7 +1206,7 @@ static void test_dbcs_to_widechar(void)
ok(wbuf[1] == 0xffff, "%04x: returned %04x (expected ffff)\n", flags[i], wbuf[1]); ok(wbuf[1] == 0xffff, "%04x: returned %04x (expected ffff)\n", flags[i], wbuf[1]);
} }
for (i = 0; i < sizeof(flags)/sizeof(DWORD); ++i) for (i = 0; i < ARRAY_SIZE(flags); ++i)
{ {
memset(wbuf, 0xff, sizeof(wbuf)); memset(wbuf, 0xff, sizeof(wbuf));
count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 3, NULL, 0); count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 3, NULL, 0);
...@@ -1232,7 +1232,7 @@ static void test_dbcs_to_widechar(void) ...@@ -1232,7 +1232,7 @@ static void test_dbcs_to_widechar(void)
} }
/* src ends with null character */ /* src ends with null character */
for (i = 0; i < sizeof(flags)/sizeof(DWORD); ++i) for (i = 0; i < ARRAY_SIZE(flags); ++i)
{ {
memset(wbuf, 0xff, sizeof(wbuf)); memset(wbuf, 0xff, sizeof(wbuf));
count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 4, NULL, 0); count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 4, NULL, 0);
...@@ -1261,7 +1261,7 @@ static void test_dbcs_to_widechar(void) ...@@ -1261,7 +1261,7 @@ static void test_dbcs_to_widechar(void)
} }
/* src has null character, but not ends with it */ /* src has null character, but not ends with it */
for (i = 0; i < sizeof(flags)/sizeof(DWORD); ++i) for (i = 0; i < ARRAY_SIZE(flags); ++i)
{ {
memset(wbuf, 0xff, sizeof(wbuf)); memset(wbuf, 0xff, sizeof(wbuf));
count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 5, NULL, 0); count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 5, NULL, 0);
......
...@@ -582,7 +582,7 @@ static void test_BuildCommDCBW(const char *string, const TEST *ptest, int initia ...@@ -582,7 +582,7 @@ static void test_BuildCommDCBW(const char *string, const TEST *ptest, int initia
WCHAR wide_string[sizeof(ptest->string)]; WCHAR wide_string[sizeof(ptest->string)];
static int reportedDCBW = 0; static int reportedDCBW = 0;
MultiByteToWideChar(CP_ACP, 0, string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, string, -1, wide_string, ARRAY_SIZE(wide_string));
/* set initial conditions */ /* set initial conditions */
memset(&dcb, initial_value, sizeof(DCB)); memset(&dcb, initial_value, sizeof(DCB));
...@@ -610,7 +610,7 @@ static void test_BuildCommDCBAndTimeoutsW(const char *string, const TEST *ptest, ...@@ -610,7 +610,7 @@ static void test_BuildCommDCBAndTimeoutsW(const char *string, const TEST *ptest,
WCHAR wide_string[sizeof(ptest->string)]; WCHAR wide_string[sizeof(ptest->string)];
static int reportedDCBAndTW = 0; static int reportedDCBAndTW = 0;
MultiByteToWideChar(CP_ACP, 0, string, -1, wide_string, sizeof(wide_string) / sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, string, -1, wide_string, ARRAY_SIZE(wide_string));
/* set initial conditions */ /* set initial conditions */
memset(&dcb, initial_value, sizeof(DCB)); memset(&dcb, initial_value, sizeof(DCB));
......
...@@ -1836,7 +1836,7 @@ static void test_DeleteFileW( void ) ...@@ -1836,7 +1836,7 @@ static void test_DeleteFileW( void )
/* test DeleteFile on empty directory */ /* test DeleteFile on empty directory */
ret = GetTempPathW(MAX_PATH, pathW); ret = GetTempPathW(MAX_PATH, pathW);
if (ret + sizeof(dirW)/sizeof(WCHAR)-1 + sizeof(subdirW)/sizeof(WCHAR)-1 >= MAX_PATH) if (ret + ARRAY_SIZE(dirW)-1 + ARRAY_SIZE(subdirW)-1 >= MAX_PATH)
{ {
ok(0, "MAX_PATH exceeded in constructing paths\n"); ok(0, "MAX_PATH exceeded in constructing paths\n");
return; return;
...@@ -2366,9 +2366,9 @@ static void test_file_sharing(void) ...@@ -2366,9 +2366,9 @@ static void test_file_sharing(void)
return; return;
} }
for (a1 = 0; a1 < sizeof(access_modes)/sizeof(access_modes[0]); a1++) for (a1 = 0; a1 < ARRAY_SIZE(access_modes); a1++)
{ {
for (s1 = 0; s1 < sizeof(sharing_modes)/sizeof(sharing_modes[0]); s1++) for (s1 = 0; s1 < ARRAY_SIZE(sharing_modes); s1++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
h = CreateFileA( filename, access_modes[a1].dw, sharing_modes[s1].dw, h = CreateFileA( filename, access_modes[a1].dw, sharing_modes[s1].dw,
...@@ -2378,9 +2378,9 @@ static void test_file_sharing(void) ...@@ -2378,9 +2378,9 @@ static void test_file_sharing(void)
ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError()); ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
return; return;
} }
for (a2 = 0; a2 < sizeof(access_modes)/sizeof(access_modes[0]); a2++) for (a2 = 0; a2 < ARRAY_SIZE(access_modes); a2++)
{ {
for (s2 = 0; s2 < sizeof(sharing_modes)/sizeof(sharing_modes[0]); s2++) for (s2 = 0; s2 < ARRAY_SIZE(sharing_modes); s2++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
h2 = CreateFileA( filename, access_modes[a2].dw, sharing_modes[s2].dw, h2 = CreateFileA( filename, access_modes[a2].dw, sharing_modes[s2].dw,
...@@ -2411,7 +2411,7 @@ static void test_file_sharing(void) ...@@ -2411,7 +2411,7 @@ static void test_file_sharing(void)
} }
} }
for (a1 = 0; a1 < sizeof(mapping_modes)/sizeof(mapping_modes[0]); a1++) for (a1 = 0; a1 < ARRAY_SIZE(mapping_modes); a1++)
{ {
HANDLE m; HANDLE m;
...@@ -2428,9 +2428,9 @@ static void test_file_sharing(void) ...@@ -2428,9 +2428,9 @@ static void test_file_sharing(void)
CloseHandle( h ); CloseHandle( h );
if (!m) continue; if (!m) continue;
for (a2 = 0; a2 < sizeof(access_modes)/sizeof(access_modes[0]); a2++) for (a2 = 0; a2 < ARRAY_SIZE(access_modes); a2++)
{ {
for (s2 = 0; s2 < sizeof(sharing_modes)/sizeof(sharing_modes[0]); s2++) for (s2 = 0; s2 < ARRAY_SIZE(sharing_modes); s2++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
h2 = CreateFileA( filename, access_modes[a2].dw, sharing_modes[s2].dw, h2 = CreateFileA( filename, access_modes[a2].dw, sharing_modes[s2].dw,
...@@ -2861,10 +2861,10 @@ static void test_FindFirstFile_wildcards(void) ...@@ -2861,10 +2861,10 @@ static void test_FindFirstFile_wildcards(void)
CreateDirectoryA("test-dir", NULL); CreateDirectoryA("test-dir", NULL);
SetCurrentDirectoryA("test-dir"); SetCurrentDirectoryA("test-dir");
for (i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (i = 0; i < ARRAY_SIZE(files); ++i)
_lclose(_lcreat(files[i], 0)); _lclose(_lcreat(files[i], 0));
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) for (i = 0; i < ARRAY_SIZE(tests); ++i)
{ {
char correct[512]; char correct[512];
char incorrect[512]; char incorrect[512];
...@@ -2901,7 +2901,7 @@ static void test_FindFirstFile_wildcards(void) ...@@ -2901,7 +2901,7 @@ static void test_FindFirstFile_wildcards(void)
missing[0] ? missing+2 : "none"); missing[0] ? missing+2 : "none");
} }
for (i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (i = 0; i < ARRAY_SIZE(files); ++i)
DeleteFileA(files[i]); DeleteFileA(files[i]);
SetCurrentDirectoryA(".."); SetCurrentDirectoryA("..");
RemoveDirectoryA("test-dir"); RemoveDirectoryA("test-dir");
...@@ -3007,7 +3007,7 @@ static void test_async_file_errors(void) ...@@ -3007,7 +3007,7 @@ static void test_async_file_errors(void)
ovl.hEvent = hSem; ovl.hEvent = hSem;
completion_count = 0; completion_count = 0;
szFile[0] = '\0'; szFile[0] = '\0';
GetWindowsDirectoryA(szFile, sizeof(szFile)/sizeof(szFile[0])-1-strlen("\\win.ini")); GetWindowsDirectoryA(szFile, ARRAY_SIZE(szFile)-1-strlen("\\win.ini"));
strcat(szFile, "\\win.ini"); strcat(szFile, "\\win.ini");
hFile = CreateFileA(szFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, hFile = CreateFileA(szFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL); NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL);
...@@ -3881,7 +3881,7 @@ todo_wine_if (i == 1) ...@@ -3881,7 +3881,7 @@ todo_wine_if (i == 1)
} }
} }
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hfile = CreateFileA(file_name, td[i].access, 0, NULL, td[i].disposition, 0, 0); hfile = CreateFileA(file_name, td[i].access, 0, NULL, td[i].disposition, 0, 0);
...@@ -3987,7 +3987,7 @@ static void test_GetFileInformationByHandleEx(void) ...@@ -3987,7 +3987,7 @@ static void test_GetFileInformationByHandleEx(void)
ok(directory != INVALID_HANDLE_VALUE, "GetFileInformationByHandleEx: failed to open the temp folder, " ok(directory != INVALID_HANDLE_VALUE, "GetFileInformationByHandleEx: failed to open the temp folder, "
"got error %u.\n", GetLastError()); "got error %u.\n", GetLastError());
for (i = 0; i < sizeof(checks) / sizeof(checks[0]); i += 1) for (i = 0; i < ARRAY_SIZE(checks); i += 1)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pGetFileInformationByHandleEx(directory, checks[i].handleClass, checks[i].ptr, checks[i].size); ret = pGetFileInformationByHandleEx(directory, checks[i].handleClass, checks[i].ptr, checks[i].size);
...@@ -4129,7 +4129,7 @@ static void test_OpenFileById(void) ...@@ -4129,7 +4129,7 @@ static void test_OpenFileById(void)
ok(ret2 != INVALID_FILE_ATTRIBUTES, ok(ret2 != INVALID_FILE_ATTRIBUTES,
"OpenFileById: GetFileAttributesA failed to find the temp file, got error %u\n", GetLastError()); "OpenFileById: GetFileAttributesA failed to find the temp file, got error %u\n", GetLastError());
ret2 = MultiByteToWideChar(CP_ACP, 0, tempFileName + strlen(tempPath), -1, tempFileNameW, sizeof(tempFileNameW)/sizeof(tempFileNameW[0])); ret2 = MultiByteToWideChar(CP_ACP, 0, tempFileName + strlen(tempPath), -1, tempFileNameW, ARRAY_SIZE(tempFileNameW));
ok(ret2, "OpenFileById: MultiByteToWideChar failed to convert tempFileName, got error %u.\n", GetLastError()); ok(ret2, "OpenFileById: MultiByteToWideChar failed to convert tempFileName, got error %u.\n", GetLastError());
tempFileNameLen = ret2 - 1; tempFileNameLen = ret2 - 1;
...@@ -4587,7 +4587,7 @@ static void test_file_access(void) ...@@ -4587,7 +4587,7 @@ static void test_file_access(void)
GetTempPathA(MAX_PATH, path); GetTempPathA(MAX_PATH, path);
GetTempFileNameA(path, "foo", 0, fname); GetTempFileNameA(path, "foo", 0, fname);
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hfile = CreateFileA(fname, td[i].access, 0, NULL, CREATE_ALWAYS, hfile = CreateFileA(fname, td[i].access, 0, NULL, CREATE_ALWAYS,
...@@ -4601,7 +4601,7 @@ static void test_file_access(void) ...@@ -4601,7 +4601,7 @@ static void test_file_access(void)
else else
ok(hfile != INVALID_HANDLE_VALUE, "%d: CreateFile error %d\n", i, GetLastError()); ok(hfile != INVALID_HANDLE_VALUE, "%d: CreateFile error %d\n", i, GetLastError());
for (j = 0; j < sizeof(td)/sizeof(td[0]); j++) for (j = 0; j < ARRAY_SIZE(td); j++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = DuplicateHandle(GetCurrentProcess(), hfile, GetCurrentProcess(), &hdup, ret = DuplicateHandle(GetCurrentProcess(), hfile, GetCurrentProcess(), &hdup,
...@@ -4843,7 +4843,7 @@ static void test_GetFinalPathNameByHandleW(void) ...@@ -4843,7 +4843,7 @@ static void test_GetFinalPathNameByHandleW(void)
success = GetVolumePathNameW(long_path, drive_part, MAX_PATH); success = GetVolumePathNameW(long_path, drive_part, MAX_PATH);
ok(success, "GetVolumePathNameW error %u\n", GetLastError()); ok(success, "GetVolumePathNameW error %u\n", GetLastError());
success = GetVolumeNameForVolumeMountPointW(drive_part, volume_path, sizeof(volume_path) / sizeof(WCHAR)); success = GetVolumeNameForVolumeMountPointW(drive_part, volume_path, ARRAY_SIZE(volume_path));
ok(success, "GetVolumeNameForVolumeMountPointW error %u\n", GetLastError()); ok(success, "GetVolumeNameForVolumeMountPointW error %u\n", GetLastError());
/* Test for VOLUME_NAME_GUID */ /* Test for VOLUME_NAME_GUID */
...@@ -4863,7 +4863,7 @@ static void test_GetFinalPathNameByHandleW(void) ...@@ -4863,7 +4863,7 @@ static void test_GetFinalPathNameByHandleW(void)
wine_dbgstr_w(file_part), wine_dbgstr_w(result_path)); wine_dbgstr_w(file_part), wine_dbgstr_w(result_path));
drive_part[lstrlenW(drive_part)-1] = 0; drive_part[lstrlenW(drive_part)-1] = 0;
success = QueryDosDeviceW(drive_part, nt_path, sizeof(nt_path) / sizeof(WCHAR)); success = QueryDosDeviceW(drive_part, nt_path, ARRAY_SIZE(nt_path));
ok(success, "QueryDosDeviceW error %u\n", GetLastError()); ok(success, "QueryDosDeviceW error %u\n", GetLastError());
/* Test for VOLUME_NAME_NT */ /* Test for VOLUME_NAME_NT */
......
...@@ -823,7 +823,7 @@ static void test_obsolete_flags(void) ...@@ -823,7 +823,7 @@ static void test_obsolete_flags(void)
return; return;
} }
for (i = 0; i < sizeof(test_global_flags)/sizeof(test_global_flags[0]); i++) for (i = 0; i < ARRAY_SIZE(test_global_flags); i++)
{ {
gbl = GlobalAlloc(test_global_flags[i].flags, 4); gbl = GlobalAlloc(test_global_flags[i].flags, 4);
ok(gbl != NULL, "GlobalAlloc failed\n"); ok(gbl != NULL, "GlobalAlloc failed\n");
......
...@@ -697,7 +697,7 @@ static void test_Loader(void) ...@@ -697,7 +697,7 @@ static void test_Loader(void)
/* prevent displaying of the "Unable to load this DLL" message box */ /* prevent displaying of the "Unable to load this DLL" message box */
SetErrorMode(SEM_FAILCRITICALERRORS); SetErrorMode(SEM_FAILCRITICALERRORS);
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
nt_header = nt_header_template; nt_header = nt_header_template;
nt_header.FileHeader.NumberOfSections = td[i].number_of_sections; nt_header.FileHeader.NumberOfSections = td[i].number_of_sections;
...@@ -922,7 +922,7 @@ static void test_Loader(void) ...@@ -922,7 +922,7 @@ static void test_Loader(void)
error_match = FALSE; error_match = FALSE;
for (error_index = 0; for (error_index = 0;
! error_match && error_index < sizeof(td[i].errors) / sizeof(DWORD); ! error_match && error_index < ARRAY_SIZE(td[i].errors);
error_index++) error_index++)
{ {
error_match = td[i].errors[error_index] == GetLastError(); error_match = td[i].errors[error_index] == GetLastError();
...@@ -1581,7 +1581,7 @@ static void test_VirtualProtect(void *base, void *section) ...@@ -1581,7 +1581,7 @@ static void test_VirtualProtect(void *base, void *section)
orig_prot = old_prot; orig_prot = old_prot;
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = VirtualQuery(section, &info, sizeof(info)); ret = VirtualQuery(section, &info, sizeof(info));
...@@ -1712,7 +1712,7 @@ static void test_section_access(void) ...@@ -1712,7 +1712,7 @@ static void test_section_access(void)
GetTempPathA(MAX_PATH, temp_path); GetTempPathA(MAX_PATH, temp_path);
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
IMAGE_NT_HEADERS nt_header; IMAGE_NT_HEADERS nt_header;
...@@ -2028,7 +2028,7 @@ static DWORD WINAPI mutex_thread_proc(void *param) ...@@ -2028,7 +2028,7 @@ static DWORD WINAPI mutex_thread_proc(void *param)
trace("%04x: mutex_thread_proc: starting\n", GetCurrentThreadId()); trace("%04x: mutex_thread_proc: starting\n", GetCurrentThreadId());
while (1) while (1)
{ {
ret = WaitForMultipleObjects(sizeof(wait_list)/sizeof(wait_list[0]), wait_list, FALSE, 50); ret = WaitForMultipleObjects(ARRAY_SIZE(wait_list), wait_list, FALSE, 50);
if (ret == WAIT_OBJECT_0) break; if (ret == WAIT_OBJECT_0) break;
else if (ret == WAIT_OBJECT_0 + 1) else if (ret == WAIT_OBJECT_0 + 1)
{ {
...@@ -3364,7 +3364,7 @@ static void test_ResolveDelayLoadedAPI(void) ...@@ -3364,7 +3364,7 @@ static void test_ResolveDelayLoadedAPI(void)
section.PointerToRawData = 0x2000; section.PointerToRawData = 0x2000;
section.VirtualAddress = 0x2000; section.VirtualAddress = 0x2000;
i = sizeof(td)/sizeof(td[0]); i = ARRAY_SIZE(td);
section.Misc.VirtualSize = sizeof(test_dll) + sizeof(hint) + sizeof(test_func) + sizeof(HMODULE) + section.Misc.VirtualSize = sizeof(test_dll) + sizeof(hint) + sizeof(test_func) + sizeof(HMODULE) +
2 * (i + 1) * sizeof(IMAGE_THUNK_DATA); 2 * (i + 1) * sizeof(IMAGE_THUNK_DATA);
ok(section.Misc.VirtualSize <= 0x1000, "Too much tests, add a new section!\n"); ok(section.Misc.VirtualSize <= 0x1000, "Too much tests, add a new section!\n");
...@@ -3413,7 +3413,7 @@ static void test_ResolveDelayLoadedAPI(void) ...@@ -3413,7 +3413,7 @@ static void test_ResolveDelayLoadedAPI(void)
SetFilePointer( hfile, idd.ImportAddressTableRVA, NULL, SEEK_SET ); SetFilePointer( hfile, idd.ImportAddressTableRVA, NULL, SEEK_SET );
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
/* 0x1a00 is an empty space between delay data and extended delay data, real thunks are not necessary */ /* 0x1a00 is an empty space between delay data and extended delay data, real thunks are not necessary */
itd32.u1.Function = nt_header.OptionalHeader.ImageBase + 0x1a00 + i * 0x20; itd32.u1.Function = nt_header.OptionalHeader.ImageBase + 0x1a00 + i * 0x20;
...@@ -3427,7 +3427,7 @@ static void test_ResolveDelayLoadedAPI(void) ...@@ -3427,7 +3427,7 @@ static void test_ResolveDelayLoadedAPI(void)
ret = WriteFile(hfile, &itd32, sizeof(itd32), &dummy, NULL); ret = WriteFile(hfile, &itd32, sizeof(itd32), &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError()); ok(ret, "WriteFile error %d\n", GetLastError());
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
if (td[i].func) if (td[i].func)
itd32.u1.AddressOfData = idd.DllNameRVA + sizeof(test_dll); itd32.u1.AddressOfData = idd.DllNameRVA + sizeof(test_dll);
...@@ -3480,7 +3480,7 @@ static void test_ResolveDelayLoadedAPI(void) ...@@ -3480,7 +3480,7 @@ static void test_ResolveDelayLoadedAPI(void)
itda = RVAToAddr(delaydir->ImportAddressTableRVA, hlib); itda = RVAToAddr(delaydir->ImportAddressTableRVA, hlib);
htarget = LoadLibraryA(RVAToAddr(delaydir->DllNameRVA, hlib)); htarget = LoadLibraryA(RVAToAddr(delaydir->DllNameRVA, hlib));
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
void *ret, *load; void *ret, *load;
......
...@@ -39,7 +39,7 @@ static BOOL cmpStrAW(const char* a, const WCHAR* b, DWORD lenA, DWORD lenB) ...@@ -39,7 +39,7 @@ static BOOL cmpStrAW(const char* a, const WCHAR* b, DWORD lenA, DWORD lenB)
WCHAR aw[1024]; WCHAR aw[1024];
DWORD len = MultiByteToWideChar( AreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, DWORD len = MultiByteToWideChar( AreFileApisANSI() ? CP_ACP : CP_OEMCP, 0,
a, lenA, aw, sizeof(aw) / sizeof(aw[0]) ); a, lenA, aw, ARRAY_SIZE(aw));
if (len != lenB) return FALSE; if (len != lenB) return FALSE;
return memcmp(aw, b, len * sizeof(WCHAR)) == 0; return memcmp(aw, b, len * sizeof(WCHAR)) == 0;
} }
...@@ -149,7 +149,7 @@ static void testGetModuleFileName(const char* name) ...@@ -149,7 +149,7 @@ static void testGetModuleFileName(const char* name)
{ {
memset(bufW, '-', sizeof(bufW)); memset(bufW, '-', sizeof(bufW));
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
len1W = GetModuleFileNameW(hMod, bufW, sizeof(bufW) / sizeof(WCHAR)); len1W = GetModuleFileNameW(hMod, bufW, ARRAY_SIZE(bufW));
ok(GetLastError() == ERROR_SUCCESS || ok(GetLastError() == ERROR_SUCCESS ||
broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */ broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
"LastError was not reset: %u\n", GetLastError()); "LastError was not reset: %u\n", GetLastError());
...@@ -191,7 +191,8 @@ static void testGetModuleFileName_Wrong(void) ...@@ -191,7 +191,8 @@ static void testGetModuleFileName_Wrong(void)
if (is_unicode_enabled) if (is_unicode_enabled)
{ {
bufW[0] = '*'; bufW[0] = '*';
ok(GetModuleFileNameW((void*)0xffffffff, bufW, sizeof(bufW) / sizeof(WCHAR)) == 0, "Unexpected success in module handle\n"); ok(GetModuleFileNameW((void*)0xffffffff, bufW, ARRAY_SIZE(bufW)) == 0,
"Unexpected success in module handle\n");
ok(bufW[0] == '*', "When failing, buffer shouldn't be written to\n"); ok(bufW[0] == '*', "When failing, buffer shouldn't be written to\n");
} }
...@@ -538,7 +539,7 @@ static void test_LoadLibraryEx_search_flags(void) ...@@ -538,7 +539,7 @@ static void test_LoadLibraryEx_search_flags(void)
ok( !mod, "LoadLibrary succeeded\n" ); ok( !mod, "LoadLibrary succeeded\n" );
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() ); ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
for (j = 0; j < sizeof(tests) / sizeof(tests[0]); j++) for (j = 0; j < ARRAY_SIZE(tests); j++)
{ {
for (k = 0; tests[j].add_dirs[k]; k++) for (k = 0; tests[j].add_dirs[k]; k++)
{ {
...@@ -598,7 +599,7 @@ static void testGetDllDirectory(void) ...@@ -598,7 +599,7 @@ static void testGetDllDirectory(void)
"C:\\Some\\Path\\", "C:\\Some\\Path\\",
"Q:\\A\\Long\\Path with spaces that\\probably\\doesn't exist!", "Q:\\A\\Long\\Path with spaces that\\probably\\doesn't exist!",
}; };
const int test_count = sizeof(dll_directories) / sizeof(dll_directories[0]); const int test_count = ARRAY_SIZE(dll_directories);
if (!pGetDllDirectoryA || !pGetDllDirectoryW) if (!pGetDllDirectoryA || !pGetDllDirectoryW)
{ {
...@@ -917,7 +918,7 @@ static void test_AddDllDirectory(void) ...@@ -917,7 +918,7 @@ static void test_AddDllDirectory(void)
} }
buf[0] = '\0'; buf[0] = '\0';
GetTempPathW( sizeof(path)/sizeof(path[0]), path ); GetTempPathW(ARRAY_SIZE(path), path );
ret = GetTempFileNameW( path, tmpW, 0, buf ); ret = GetTempFileNameW( path, tmpW, 0, buf );
ok( ret, "GetTempFileName failed err %u\n", GetLastError() ); ok( ret, "GetTempFileName failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
......
...@@ -2381,9 +2381,8 @@ static void test_NamedPipeHandleState(void) ...@@ -2381,9 +2381,8 @@ static void test_NamedPipeHandleState(void)
* on a local pipe. * on a local pipe.
*/ */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetNamedPipeHandleStateA(server, &state, &instances, ret = GetNamedPipeHandleStateA(server, &state, &instances, &maxCollectionCount,
&maxCollectionCount, &collectDataTimeout, userName, &collectDataTimeout, userName, ARRAY_SIZE(userName));
sizeof(userName) / sizeof(userName[0]));
todo_wine todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
......
...@@ -423,7 +423,7 @@ static void doChild(const char* file, const char* option) ...@@ -423,7 +423,7 @@ static void doChild(const char* file, const char* option)
childPrintf(hFile, "[Misc]\n"); childPrintf(hFile, "[Misc]\n");
if (GetCurrentDirectoryA(sizeof(bufA), bufA)) if (GetCurrentDirectoryA(sizeof(bufA), bufA))
childPrintf(hFile, "CurrDirA=%s\n", encodeA(bufA)); childPrintf(hFile, "CurrDirA=%s\n", encodeA(bufA));
if (GetCurrentDirectoryW(sizeof(bufW) / sizeof(bufW[0]), bufW)) if (GetCurrentDirectoryW(ARRAY_SIZE(bufW), bufW))
childPrintf(hFile, "CurrDirW=%s\n", encodeW(bufW)); childPrintf(hFile, "CurrDirW=%s\n", encodeW(bufW));
childPrintf(hFile, "\n"); childPrintf(hFile, "\n");
...@@ -1987,14 +1987,14 @@ static void test_QueryFullProcessImageNameW(void) ...@@ -1987,14 +1987,14 @@ static void test_QueryFullProcessImageNameW(void)
ok(GetModuleFileNameW(NULL, module_name, 1024), "GetModuleFileNameW(NULL, ...) failed\n"); ok(GetModuleFileNameW(NULL, module_name, 1024), "GetModuleFileNameW(NULL, ...) failed\n");
/* GetCurrentProcess pseudo-handle */ /* GetCurrentProcess pseudo-handle */
size = sizeof(buf) / sizeof(buf[0]); size = ARRAY_SIZE(buf);
expect_eq_d(TRUE, pQueryFullProcessImageNameW(GetCurrentProcess(), 0, buf, &size)); expect_eq_d(TRUE, pQueryFullProcessImageNameW(GetCurrentProcess(), 0, buf, &size));
expect_eq_d(lstrlenW(buf), size); expect_eq_d(lstrlenW(buf), size);
expect_eq_ws_i(buf, module_name); expect_eq_ws_i(buf, module_name);
hSelf = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, GetCurrentProcessId()); hSelf = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, GetCurrentProcessId());
/* Real handle */ /* Real handle */
size = sizeof(buf) / sizeof(buf[0]); size = ARRAY_SIZE(buf);
expect_eq_d(TRUE, pQueryFullProcessImageNameW(hSelf, 0, buf, &size)); expect_eq_d(TRUE, pQueryFullProcessImageNameW(hSelf, 0, buf, &size));
expect_eq_d(lstrlenW(buf), size); expect_eq_d(lstrlenW(buf), size);
expect_eq_ws_i(buf, module_name); expect_eq_ws_i(buf, module_name);
...@@ -2032,7 +2032,7 @@ static void test_QueryFullProcessImageNameW(void) ...@@ -2032,7 +2032,7 @@ static void test_QueryFullProcessImageNameW(void)
/* native path */ /* native path */
size = sizeof(buf) / sizeof(buf[0]); size = ARRAY_SIZE(buf);
expect_eq_d(TRUE, pQueryFullProcessImageNameW(hSelf, PROCESS_NAME_NATIVE, buf, &size)); expect_eq_d(TRUE, pQueryFullProcessImageNameW(hSelf, PROCESS_NAME_NATIVE, buf, &size));
expect_eq_d(lstrlenW(buf), size); expect_eq_d(lstrlenW(buf), size);
ok(buf[0] == '\\', "NT path should begin with '\\'\n"); ok(buf[0] == '\\', "NT path should begin with '\\'\n");
...@@ -2040,7 +2040,7 @@ static void test_QueryFullProcessImageNameW(void) ...@@ -2040,7 +2040,7 @@ static void test_QueryFullProcessImageNameW(void)
module_name[2] = '\0'; module_name[2] = '\0';
*device = '\0'; *device = '\0';
size = QueryDosDeviceW(module_name, device, sizeof(device)/sizeof(device[0])); size = QueryDosDeviceW(module_name, device, ARRAY_SIZE(device));
ok(size, "QueryDosDeviceW failed: le=%u\n", GetLastError()); ok(size, "QueryDosDeviceW failed: le=%u\n", GetLastError());
len = lstrlenW(device); len = lstrlenW(device);
ok(size >= len+2, "expected %d to be greater than %d+2 = strlen(%s)\n", size, len, wine_dbgstr_w(device)); ok(size >= len+2, "expected %d to be greater than %d+2 = strlen(%s)\n", size, len, wine_dbgstr_w(device));
......
...@@ -71,7 +71,7 @@ static void test_profile_int(void) ...@@ -71,7 +71,7 @@ static void test_profile_int(void)
{ SECTION, KEY, "B4294967297", TESTFILE, -1, 0 , 0}, { SECTION, KEY, "B4294967297", TESTFILE, -1, 0 , 0},
{ SECTION, KEY, "B4294967297", TESTFILE, 1, 0 , 0}, { SECTION, KEY, "B4294967297", TESTFILE, 1, 0 , 0},
}; };
int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt)); int i, num_test = ARRAY_SIZE(profileInt);
UINT res; UINT res;
DeleteFileA( TESTFILE); DeleteFileA( TESTFILE);
...@@ -144,8 +144,7 @@ static void test_profile_string(void) ...@@ -144,8 +144,7 @@ static void test_profile_string(void)
CloseHandle( h); CloseHandle( h);
/* works only in unicode, ascii crashes */ /* works only in unicode, ascii crashes */
ret=GetPrivateProfileStringW(emptyW, keyW, emptyW, bufW, ret=GetPrivateProfileStringW(emptyW, keyW, emptyW, bufW, ARRAY_SIZE(bufW), TESTFILE2W);
sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
todo_wine todo_wine
ok(ret == 13, "expected 13, got %u\n", ret); ok(ret == 13, "expected 13, got %u\n", ret);
todo_wine todo_wine
...@@ -153,8 +152,7 @@ static void test_profile_string(void) ...@@ -153,8 +152,7 @@ static void test_profile_string(void)
wine_dbgstr_w(valsectionW), wine_dbgstr_w(bufW) ); wine_dbgstr_w(valsectionW), wine_dbgstr_w(bufW) );
/* works only in unicode, ascii crashes */ /* works only in unicode, ascii crashes */
ret=GetPrivateProfileStringW(sW, emptyW, emptyW, bufW, ret=GetPrivateProfileStringW(sW, emptyW, emptyW, bufW, ARRAY_SIZE(bufW), TESTFILE2W);
sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
todo_wine todo_wine
ok(ret == 10, "expected 10, got %u\n", ret); ok(ret == 10, "expected 10, got %u\n", ret);
todo_wine todo_wine
...@@ -394,7 +392,7 @@ static void test_profile_existing(void) ...@@ -394,7 +392,7 @@ static void test_profile_existing(void)
HANDLE h = 0; HANDLE h = 0;
char buffer[MAX_PATH]; char buffer[MAX_PATH];
for (i=0; i < sizeof(pe)/sizeof(pe[0]); i++) for (i=0; i < ARRAY_SIZE(pe); i++)
{ {
h = CreateFileA(testfile1, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL, h = CreateFileA(testfile1, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
...@@ -434,7 +432,7 @@ static void test_profile_existing(void) ...@@ -434,7 +432,7 @@ static void test_profile_existing(void)
ok( WriteFile( h, buffer, strlen(buffer), &size, NULL ), "failed to write\n" ); ok( WriteFile( h, buffer, strlen(buffer), &size, NULL ), "failed to write\n" );
CloseHandle( h ); CloseHandle( h );
for (i=0; i < sizeof(pe)/sizeof(pe[0]); i++) for (i=0; i < ARRAY_SIZE(pe); i++)
{ {
h = CreateFileA(testfile2, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL, h = CreateFileA(testfile2, pe[i].dwDesiredAccess, pe[i].dwShareMode, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
......
...@@ -478,7 +478,7 @@ START_TEST(resource) ...@@ -478,7 +478,7 @@ START_TEST(resource)
update_empty_exe(); update_empty_exe();
for(i=0; i < sizeof( sec_variants ) / sizeof( sec_variants[0] ); i++) for(i=0; i < ARRAY_SIZE(sec_variants); i++)
{ {
const struct _sec_variants *sec = &sec_variants[i]; const struct _sec_variants *sec = &sec_variants[i];
build_exe( &sec->build ); build_exe( &sec->build );
......
...@@ -1933,7 +1933,7 @@ static void test_thread_info(void) ...@@ -1933,7 +1933,7 @@ static void test_thread_info(void)
return; return;
} }
for (i = 0; i < sizeof(info_size)/sizeof(info_size[0]); i++) for (i = 0; i < ARRAY_SIZE(info_size); i++)
{ {
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
......
...@@ -606,7 +606,7 @@ static void test_VerifyVersionInfo(void) ...@@ -606,7 +606,7 @@ static void test_VerifyVersionInfo(void)
} }
} }
for (i = 0; i < sizeof(verify_version_tests)/sizeof(verify_version_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(verify_version_tests); i++)
{ {
struct verify_version_test *test = &verify_version_tests[i]; struct verify_version_test *test = &verify_version_tests[i];
DWORD srcinfo = test->srcinfo; DWORD srcinfo = test->srcinfo;
......
...@@ -1716,7 +1716,7 @@ static void test_CreateFileMapping(void) ...@@ -1716,7 +1716,7 @@ static void test_CreateFileMapping(void)
file[2] = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 ); file[2] = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
ok( file[2] != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() ); ok( file[2] != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
for (i = 0; i < sizeof(sec_flag_tests) / sizeof(sec_flag_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(sec_flag_tests); i++)
{ {
DWORD flags = sec_flag_tests[i].flags; DWORD flags = sec_flag_tests[i].flags;
DWORD perm = sec_flag_tests[i].file == 2 ? PAGE_READONLY : PAGE_READWRITE; DWORD perm = sec_flag_tests[i].file == 2 ? PAGE_READONLY : PAGE_READWRITE;
...@@ -3333,7 +3333,7 @@ static void test_VirtualProtect(void) ...@@ -3333,7 +3333,7 @@ static void test_VirtualProtect(void)
ok(status == STATUS_SUCCESS, "NtProtectVirtualMemory should succeed, got %08x\n", status); ok(status == STATUS_SUCCESS, "NtProtectVirtualMemory should succeed, got %08x\n", status);
ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot); ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = VirtualQuery(base, &info, sizeof(info)); ret = VirtualQuery(base, &info, sizeof(info));
...@@ -3499,7 +3499,7 @@ static void test_VirtualAlloc_protection(void) ...@@ -3499,7 +3499,7 @@ static void test_VirtualAlloc_protection(void)
DWORD ret, i; DWORD ret, i;
MEMORY_BASIC_INFORMATION info; MEMORY_BASIC_INFORMATION info;
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
base = VirtualAlloc(0, si.dwPageSize, MEM_COMMIT, td[i].prot); base = VirtualAlloc(0, si.dwPageSize, MEM_COMMIT, td[i].prot);
...@@ -3602,7 +3602,7 @@ static void test_CreateFileMapping_protection(void) ...@@ -3602,7 +3602,7 @@ static void test_CreateFileMapping_protection(void)
SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN); SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN);
SetEndOfFile(hfile); SetEndOfFile(hfile);
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmap = CreateFileMappingW(hfile, NULL, td[i].prot | SEC_COMMIT, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, td[i].prot | SEC_COMMIT, 0, si.dwPageSize, NULL);
...@@ -3674,7 +3674,7 @@ static void test_CreateFileMapping_protection(void) ...@@ -3674,7 +3674,7 @@ static void test_CreateFileMapping_protection(void)
hmap = CreateFileMappingW(hfile, NULL, alloc_prot, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, alloc_prot, 0, si.dwPageSize, NULL);
ok(hmap != 0, "%d: CreateFileMapping error %d\n", i, GetLastError()); ok(hmap != 0, "%d: CreateFileMapping error %d\n", i, GetLastError());
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) for (i = 0; i < ARRAY_SIZE(td); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
base = MapViewOfFile(hmap, FILE_MAP_READ | FILE_MAP_WRITE | (page_exec_supported ? FILE_MAP_EXECUTE : 0), 0, 0, 0); base = MapViewOfFile(hmap, FILE_MAP_READ | FILE_MAP_WRITE | (page_exec_supported ? FILE_MAP_EXECUTE : 0), 0, 0, 0);
...@@ -3941,7 +3941,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags ) ...@@ -3941,7 +3941,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
BOOL anon_mapping = (hfile == INVALID_HANDLE_VALUE); BOOL anon_mapping = (hfile == INVALID_HANDLE_VALUE);
trace( "testing %s mapping flags %08x\n", anon_mapping ? "anonymous" : "file", sec_flags ); trace( "testing %s mapping flags %08x\n", anon_mapping ? "anonymous" : "file", sec_flags );
for (i = 0; i < sizeof(page_prot)/sizeof(page_prot[0]); i++) for (i = 0; i < ARRAY_SIZE(page_prot); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmap = CreateFileMappingW(hfile, NULL, page_prot[i] | sec_flags, 0, si.dwPageSize, NULL); hmap = CreateFileMappingW(hfile, NULL, page_prot[i] | sec_flags, 0, si.dwPageSize, NULL);
...@@ -3998,7 +3998,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags ) ...@@ -3998,7 +3998,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
ok(hmap != 0, "%d: CreateFileMapping(%04x) error %d\n", i, page_prot[i], GetLastError()); ok(hmap != 0, "%d: CreateFileMapping(%04x) error %d\n", i, page_prot[i], GetLastError());
for (j = 0; j < sizeof(view)/sizeof(view[0]); j++) for (j = 0; j < ARRAY_SIZE(view); j++)
{ {
nt_base = map_view_of_file(hmap, view[j].access); nt_base = map_view_of_file(hmap, view[j].access);
if (nt_base) if (nt_base)
...@@ -4085,7 +4085,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags ) ...@@ -4085,7 +4085,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
prev_prot = info.Protect; prev_prot = info.Protect;
alloc_prot = info.AllocationProtect; alloc_prot = info.AllocationProtect;
for (k = 0; k < sizeof(page_prot)/sizeof(page_prot[0]); k++) for (k = 0; k < ARRAY_SIZE(page_prot); k++)
{ {
/*trace("map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);*/ /*trace("map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);*/
DWORD actual_prot = (sec_flags & SEC_IMAGE) ? map_prot_no_write(page_prot[k]) : page_prot[k]; DWORD actual_prot = (sec_flags & SEC_IMAGE) ? map_prot_no_write(page_prot[k]) : page_prot[k];
...@@ -4118,7 +4118,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags ) ...@@ -4118,7 +4118,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
} }
} }
for (k = 0; k < sizeof(page_prot)/sizeof(page_prot[0]); k++) for (k = 0; k < ARRAY_SIZE(page_prot); k++)
{ {
/*trace("map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);*/ /*trace("map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);*/
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
...@@ -4172,7 +4172,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags ) ...@@ -4172,7 +4172,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
prev_prot = info.Protect; prev_prot = info.Protect;
alloc_prot = info.AllocationProtect; alloc_prot = info.AllocationProtect;
for (k = 0; k < sizeof(page_prot)/sizeof(page_prot[0]); k++) for (k = 0; k < ARRAY_SIZE(page_prot); k++)
{ {
DWORD actual_prot = (sec_flags & SEC_IMAGE) ? map_prot_no_write(page_prot[k]) : page_prot[k]; DWORD actual_prot = (sec_flags & SEC_IMAGE) ? map_prot_no_write(page_prot[k]) : page_prot[k];
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
......
...@@ -251,7 +251,7 @@ static void test_GetVolumeNameForVolumeMountPointW(void) ...@@ -251,7 +251,7 @@ static void test_GetVolumeNameForVolumeMountPointW(void)
{ {
BOOL ret; BOOL ret;
WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0}; WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
DWORD len = sizeof(volume) / sizeof(WCHAR); DWORD len = ARRAY_SIZE(volume);
/* not present before w2k */ /* not present before w2k */
if (!pGetVolumeNameForVolumeMountPointW) { if (!pGetVolumeNameForVolumeMountPointW) {
...@@ -795,7 +795,7 @@ static void test_GetVolumePathNameA(void) ...@@ -795,7 +795,7 @@ static void test_GetVolumePathNameA(void)
ret = SetEnvironmentVariableA( "CurrentDrive", cwd ); ret = SetEnvironmentVariableA( "CurrentDrive", cwd );
ok( ret, "Failed to set an environment variable for the current working drive.\n" ); ok( ret, "Failed to set an environment variable for the current working drive.\n" );
for (i=0; i<sizeof(test_paths)/sizeof(test_paths[0]); i++) for (i=0; i<ARRAY_SIZE(test_paths); i++)
{ {
BOOL broken_ret = test_paths[i].broken_error == NO_ERROR; BOOL broken_ret = test_paths[i].broken_error == NO_ERROR;
char *output = (test_paths[i].path_name != NULL ? volume_path : NULL); char *output = (test_paths[i].path_name != NULL ? volume_path : NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment