Commit 94d8ba78 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

parent c57b9b8d
...@@ -121,7 +121,7 @@ static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey) ...@@ -121,7 +121,7 @@ static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
dwMaxSubkeyLen++; dwMaxSubkeyLen++;
dwMaxValueLen++; dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen); dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR)) if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{ {
/* Name too big: alloc a buffer for it */ /* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR)))) if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
...@@ -1259,7 +1259,7 @@ static void testSetupDiGetINFClassA(void) ...@@ -1259,7 +1259,7 @@ static void testSetupDiGetINFClassA(void)
retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count); retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count);
ok(!retval, "expected SetupDiGetINFClassA to fail!\n"); ok(!retval, "expected SetupDiGetINFClassA to fail!\n");
for(i=0; i < sizeof(signatures)/sizeof(char*); i++) for(i=0; i < ARRAY_SIZE(signatures); i++)
{ {
trace("testing signature %s\n", signatures[i]); trace("testing signature %s\n", signatures[i]);
h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
......
...@@ -594,7 +594,7 @@ static void test_SetupDecompressOrCopyFile(void) ...@@ -594,7 +594,7 @@ static void test_SetupDecompressOrCopyFile(void)
create_source_file(source, uncompressed, sizeof(uncompressed)); create_source_file(source, uncompressed, sizeof(uncompressed));
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++) for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{ {
type = FILE_COMPRESSION_NONE; type = FILE_COMPRESSION_NONE;
ret = SetupDecompressOrCopyFileA(invalid_parameters[i].source, ret = SetupDecompressOrCopyFileA(invalid_parameters[i].source,
...@@ -697,7 +697,7 @@ static void test_SetupDecompressOrCopyFile(void) ...@@ -697,7 +697,7 @@ static void test_SetupDecompressOrCopyFile(void)
p = strrchr(target, '\\'); p = strrchr(target, '\\');
for (i = 0; i < sizeof(zip_multi_tests)/sizeof(zip_multi_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(zip_multi_tests); i++)
{ {
lstrcpyA(p + 1, zip_multi_tests[i].filename); lstrcpyA(p + 1, zip_multi_tests[i].filename);
......
...@@ -154,7 +154,7 @@ static void test_invalid_files(void) ...@@ -154,7 +154,7 @@ static void test_invalid_files(void)
HINF hinf; HINF hinf;
DWORD err; DWORD err;
for (i = 0; i < sizeof(invalid_files)/sizeof(invalid_files[0]); i++) for (i = 0; i < ARRAY_SIZE(invalid_files); i++)
{ {
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
err_line = 0xdeadbeef; err_line = 0xdeadbeef;
...@@ -229,7 +229,7 @@ static void test_section_names(void) ...@@ -229,7 +229,7 @@ static void test_section_names(void)
DWORD err; DWORD err;
LONG ret; LONG ret;
for (i = 0; i < sizeof(section_names)/sizeof(section_names[0]); i++) for (i = 0; i < ARRAY_SIZE(section_names); i++)
{ {
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
hinf = test_file_contents( section_names[i].data, &err_line ); hinf = test_file_contents( section_names[i].data, &err_line );
...@@ -418,7 +418,7 @@ static void test_key_names(void) ...@@ -418,7 +418,7 @@ static void test_key_names(void)
BOOL ret; BOOL ret;
INFCONTEXT context; INFCONTEXT context;
for (i = 0; i < sizeof(key_names)/sizeof(key_names[0]); i++) for (i = 0; i < ARRAY_SIZE(key_names); i++)
{ {
strcpy( buffer, STD_HEADER "[Test]\n" ); strcpy( buffer, STD_HEADER "[Test]\n" );
strcat( buffer, key_names[i].data ); strcat( buffer, key_names[i].data );
...@@ -622,7 +622,7 @@ static void test_SetupGetIntField(void) ...@@ -622,7 +622,7 @@ static void test_SetupGetIntField(void)
}; };
unsigned int i; unsigned int i;
for (i = 0; i < sizeof(keys)/sizeof(keys[0]); i++) for (i = 0; i < ARRAY_SIZE(keys); i++)
{ {
HINF hinf; HINF hinf;
char buffer[MAX_INF_STRING_LENGTH]; char buffer[MAX_INF_STRING_LENGTH];
......
...@@ -109,7 +109,7 @@ static void test_invalid_parametersA(void) ...@@ -109,7 +109,7 @@ static void test_invalid_parametersA(void)
create_source_fileA(source, NULL, 0); create_source_fileA(source, NULL, 0);
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++) for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = SetupIterateCabinetA(invalid_parameters[i].CabinetFile, 0, ret = SetupIterateCabinetA(invalid_parameters[i].CabinetFile, 0,
...@@ -170,12 +170,12 @@ static void test_invalid_parametersW(void) ...@@ -170,12 +170,12 @@ static void test_invalid_parametersW(void)
return; return;
} }
GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp); GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source); GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, NULL, 0); create_source_fileW(source, NULL, 0);
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++) for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = SetupIterateCabinetW(invalid_parameters[i].CabinetFile, 0, ret = SetupIterateCabinetW(invalid_parameters[i].CabinetFile, 0,
...@@ -275,7 +275,7 @@ static void test_invalid_callbackW(void) ...@@ -275,7 +275,7 @@ static void test_invalid_callbackW(void)
return; return;
} }
GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp); GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source); GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi)); create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));
...@@ -316,7 +316,7 @@ static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification, ...@@ -316,7 +316,7 @@ static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification,
(*file_count)++; (*file_count)++;
if (index < sizeof(expected_files)/sizeof(char *)) if (index < ARRAY_SIZE(expected_files))
{ {
ok(!strcmp(expected_files[index], info->NameInCabinet), ok(!strcmp(expected_files[index], info->NameInCabinet),
"[%d] Expected file \"%s\", got \"%s\"\n", "[%d] Expected file \"%s\", got \"%s\"\n",
...@@ -348,8 +348,7 @@ static void test_simple_enumerationA(void) ...@@ -348,8 +348,7 @@ static void test_simple_enumerationA(void)
ret = SetupIterateCabinetA(source, 0, simple_callbackA, &enum_count); ret = SetupIterateCabinetA(source, 0, simple_callbackA, &enum_count);
ok(ret == 1, "Expected SetupIterateCabinetA to return 1, got %d\n", ret); ok(ret == 1, "Expected SetupIterateCabinetA to return 1, got %d\n", ret);
ok(enum_count == sizeof(expected_files)/sizeof(char *), ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count);
"Unexpectedly enumerated %d files\n", enum_count);
DeleteFileA(source); DeleteFileA(source);
} }
...@@ -376,7 +375,7 @@ static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification, ...@@ -376,7 +375,7 @@ static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification,
(*file_count)++; (*file_count)++;
if (index < sizeof(expected_filesW)/sizeof(WCHAR *)) if (index < ARRAY_SIZE(expected_filesW))
{ {
ok(!lstrcmpW(expected_filesW[index], info->NameInCabinet), ok(!lstrcmpW(expected_filesW[index], info->NameInCabinet),
"[%d] Expected file %s, got %s\n", "[%d] Expected file %s, got %s\n",
...@@ -408,15 +407,14 @@ static void test_simple_enumerationW(void) ...@@ -408,15 +407,14 @@ static void test_simple_enumerationW(void)
return; return;
} }
GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp); GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source); GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi)); create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));
ret = SetupIterateCabinetW(source, 0, simple_callbackW, &enum_count); ret = SetupIterateCabinetW(source, 0, simple_callbackW, &enum_count);
ok(ret == 1, "Expected SetupIterateCabinetW to return 1, got %d\n", ret); ok(ret == 1, "Expected SetupIterateCabinetW to return 1, got %d\n", ret);
ok(enum_count == sizeof(expected_files)/sizeof(WCHAR *), ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count);
"Unexpectedly enumerated %d files\n", enum_count);
DeleteFileW(source); DeleteFileW(source);
} }
......
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