advapi32/tests: Introduce ARRAY_SIZE macro.
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
89e2cf6b2b
commit
9702de2002
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||||
|
|
||||||
static BOOL (WINAPI *pCredDeleteA)(LPCSTR,DWORD,DWORD);
|
static BOOL (WINAPI *pCredDeleteA)(LPCSTR,DWORD,DWORD);
|
||||||
static BOOL (WINAPI *pCredEnumerateA)(LPCSTR,DWORD,DWORD *,PCREDENTIALA **);
|
static BOOL (WINAPI *pCredEnumerateA)(LPCSTR,DWORD,DWORD *,PCREDENTIALA **);
|
||||||
static VOID (WINAPI *pCredFree)(PVOID);
|
static VOID (WINAPI *pCredFree)(PVOID);
|
||||||
|
@ -658,7 +660,7 @@ static void test_CredUnmarshalCredentialA(void)
|
||||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
||||||
{
|
{
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
type = 0;
|
type = 0;
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||||
|
|
||||||
static BOOL (WINAPI *pCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
|
static BOOL (WINAPI *pCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
|
||||||
static BOOL (WINAPI *pGetEventLogInformation)(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
|
static BOOL (WINAPI *pGetEventLogInformation)(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
|
||||||
|
|
||||||
|
@ -674,7 +676,7 @@ static BOOL create_new_eventlog(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create some event sources, the registry value 'Sources' is updated automatically */
|
/* Create some event sources, the registry value 'Sources' is updated automatically */
|
||||||
for (i = 0; i < sizeof(eventsources)/sizeof(eventsources[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(eventsources); i++)
|
||||||
{
|
{
|
||||||
HKEY srckey;
|
HKEY srckey;
|
||||||
|
|
||||||
|
@ -833,7 +835,7 @@ static void test_readwrite(void)
|
||||||
CloseEventLog(handle);
|
CloseEventLog(handle);
|
||||||
|
|
||||||
/* Write a bunch of events while using different event sources */
|
/* Write a bunch of events while using different event sources */
|
||||||
for (i = 0; i < sizeof(read_write)/sizeof(read_write[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(read_write); i++)
|
||||||
{
|
{
|
||||||
DWORD oldest;
|
DWORD oldest;
|
||||||
BOOL run_sidtests = read_write[i].evt_sid & sidavailable;
|
BOOL run_sidtests = read_write[i].evt_sid & sidavailable;
|
||||||
|
@ -1074,7 +1076,7 @@ static void test_autocreation(void)
|
||||||
/* Build the expected string */
|
/* Build the expected string */
|
||||||
memset(sources_verify, 0, sizeof(sources_verify));
|
memset(sources_verify, 0, sizeof(sources_verify));
|
||||||
p = sources_verify;
|
p = sources_verify;
|
||||||
for (i = sizeof(eventsources)/sizeof(eventsources[0]); i > 0; i--)
|
for (i = ARRAY_SIZE(eventsources); i > 0; i--)
|
||||||
{
|
{
|
||||||
lstrcpyA(p, eventsources[i - 1]);
|
lstrcpyA(p, eventsources[i - 1]);
|
||||||
p += (lstrlenA(eventsources[i - 1]) + 1);
|
p += (lstrlenA(eventsources[i - 1]) + 1);
|
||||||
|
@ -1132,7 +1134,7 @@ static void cleanup_eventlog(void)
|
||||||
lstrcatA(winesvc, eventlogname);
|
lstrcatA(winesvc, eventlogname);
|
||||||
|
|
||||||
RegOpenKeyA(HKEY_LOCAL_MACHINE, winesvc, &key);
|
RegOpenKeyA(HKEY_LOCAL_MACHINE, winesvc, &key);
|
||||||
for (i = 0; i < sizeof(eventsources)/sizeof(eventsources[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(eventsources); i++)
|
||||||
RegDeleteKeyA(key, eventsources[i]);
|
RegDeleteKeyA(key, eventsources[i]);
|
||||||
RegDeleteValueA(key, "Sources");
|
RegDeleteValueA(key, "Sources");
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "aclapi.h"
|
#include "aclapi.h"
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||||
#define IS_HKCR(hk) ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2)
|
#define IS_HKCR(hk) ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2)
|
||||||
|
|
||||||
static HKEY hkey_main;
|
static HKEY hkey_main;
|
||||||
|
@ -66,7 +67,7 @@ static char *get_temp_buffer( int size )
|
||||||
char *ret;
|
char *ret;
|
||||||
UINT idx;
|
UINT idx;
|
||||||
|
|
||||||
idx = ++pos % (sizeof(list)/sizeof(list[0]));
|
idx = ++pos % ARRAY_SIZE(list);
|
||||||
if (list[idx])
|
if (list[idx])
|
||||||
ret = HeapReAlloc( GetProcessHeap(), 0, list[idx], size );
|
ret = HeapReAlloc( GetProcessHeap(), 0, list[idx], size );
|
||||||
else
|
else
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||||
|
|
||||||
#ifndef PROCESS_QUERY_LIMITED_INFORMATION
|
#ifndef PROCESS_QUERY_LIMITED_INFORMATION
|
||||||
#define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
|
#define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
|
||||||
#endif
|
#endif
|
||||||
|
@ -365,7 +367,7 @@ static void test_sid(void)
|
||||||
LocalFree(str);
|
LocalFree(str);
|
||||||
LocalFree(psid);
|
LocalFree(psid);
|
||||||
|
|
||||||
for( i = 0; i < sizeof(refs) / sizeof(refs[0]); i++ )
|
for( i = 0; i < ARRAY_SIZE(refs); i++ )
|
||||||
{
|
{
|
||||||
r = AllocateAndInitializeSid( &refs[i].auth, 1,1,0,0,0,0,0,0,0,
|
r = AllocateAndInitializeSid( &refs[i].auth, 1,1,0,0,0,0,0,0,0,
|
||||||
&psid );
|
&psid );
|
||||||
|
@ -412,7 +414,7 @@ static void test_sid(void)
|
||||||
}
|
}
|
||||||
LocalFree(psid);
|
LocalFree(psid);
|
||||||
|
|
||||||
for(i = 0; i < sizeof(strsid_table) / sizeof(strsid_table[0]); i++)
|
for(i = 0; i < ARRAY_SIZE(strsid_table); i++)
|
||||||
{
|
{
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
|
@ -787,7 +789,7 @@ static void test_lookupPrivilegeValue(void)
|
||||||
ok( ret,
|
ok( ret,
|
||||||
"LookupPrivilegeValueA(NULL, sEcREATEtOKENpRIVILEGE, &luid) failed: %d\n",
|
"LookupPrivilegeValueA(NULL, sEcREATEtOKENpRIVILEGE, &luid) failed: %d\n",
|
||||||
GetLastError());
|
GetLastError());
|
||||||
for (i = 0; i < sizeof(privs) / sizeof(privs[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(privs); i++)
|
||||||
{
|
{
|
||||||
/* Not all privileges are implemented on all Windows versions, so
|
/* Not all privileges are implemented on all Windows versions, so
|
||||||
* don't worry if the call fails
|
* don't worry if the call fails
|
||||||
|
@ -1879,7 +1881,7 @@ static void test_token_attr(void)
|
||||||
for (i = 0; i < Privileges->PrivilegeCount; i++)
|
for (i = 0; i < Privileges->PrivilegeCount; i++)
|
||||||
{
|
{
|
||||||
CHAR Name[256];
|
CHAR Name[256];
|
||||||
DWORD NameLen = sizeof(Name)/sizeof(Name[0]);
|
DWORD NameLen = ARRAY_SIZE(Name);
|
||||||
LookupPrivilegeNameA(NULL, &Privileges->Privileges[i].Luid, Name, &NameLen);
|
LookupPrivilegeNameA(NULL, &Privileges->Privileges[i].Luid, Name, &NameLen);
|
||||||
trace("\t%s, 0x%x\n", Name, Privileges->Privileges[i].Attributes);
|
trace("\t%s, 0x%x\n", Name, Privileges->Privileges[i].Attributes);
|
||||||
}
|
}
|
||||||
|
@ -2072,7 +2074,7 @@ static void test_CreateWellKnownSid(void)
|
||||||
/* a domain sid usually have three subauthorities but we test that CreateWellKnownSid doesn't check it */
|
/* a domain sid usually have three subauthorities but we test that CreateWellKnownSid doesn't check it */
|
||||||
AllocateAndInitializeSid(&ident, 6, SECURITY_NT_NON_UNIQUE, 12, 23, 34, 45, 56, 0, 0, &domainsid);
|
AllocateAndInitializeSid(&ident, 6, SECURITY_NT_NON_UNIQUE, 12, 23, 34, 45, 56, 0, 0, &domainsid);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(well_known_sid_values)/sizeof(well_known_sid_values[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(well_known_sid_values); i++)
|
||||||
{
|
{
|
||||||
const struct well_known_sid_value *value = &well_known_sid_values[i];
|
const struct well_known_sid_value *value = &well_known_sid_values[i];
|
||||||
char sid_buffer[SECURITY_MAX_SID_SIZE];
|
char sid_buffer[SECURITY_MAX_SID_SIZE];
|
||||||
|
@ -4193,7 +4195,7 @@ static void test_ConvertStringSecurityDescriptor(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(cssd)/sizeof(cssd[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(cssd); i++)
|
||||||
{
|
{
|
||||||
DWORD GLE;
|
DWORD GLE;
|
||||||
|
|
||||||
|
@ -5330,7 +5332,7 @@ static void test_mutex_security(HANDLE token)
|
||||||
access = get_obj_access(mutex);
|
access = get_obj_access(mutex);
|
||||||
ok(access == MUTANT_ALL_ACCESS, "expected MUTANT_ALL_ACCESS, got %#x\n", access);
|
ok(access == MUTANT_ALL_ACCESS, "expected MUTANT_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), mutex, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), mutex, GetCurrentProcess(), &dup,
|
||||||
|
@ -5387,7 +5389,7 @@ static void test_event_security(HANDLE token)
|
||||||
access = get_obj_access(event);
|
access = get_obj_access(event);
|
||||||
ok(access == EVENT_ALL_ACCESS, "expected EVENT_ALL_ACCESS, got %#x\n", access);
|
ok(access == EVENT_ALL_ACCESS, "expected EVENT_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), event, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), event, GetCurrentProcess(), &dup,
|
||||||
|
@ -5444,7 +5446,7 @@ static void test_semaphore_security(HANDLE token)
|
||||||
access = get_obj_access(sem);
|
access = get_obj_access(sem);
|
||||||
ok(access == SEMAPHORE_ALL_ACCESS, "expected SEMAPHORE_ALL_ACCESS, got %#x\n", access);
|
ok(access == SEMAPHORE_ALL_ACCESS, "expected SEMAPHORE_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), sem, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), sem, GetCurrentProcess(), &dup,
|
||||||
|
@ -5497,7 +5499,7 @@ static void test_named_pipe_security(HANDLE token)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Test the different security access options for pipes */
|
/* Test the different security access options for pipes */
|
||||||
for (i = 0; i < sizeof(creation_access)/sizeof(creation_access[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(creation_access); i++)
|
||||||
{
|
{
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
pipe = CreateNamedPipeA(WINE_TEST_PIPE, creation_access[i].open_mode,
|
pipe = CreateNamedPipeA(WINE_TEST_PIPE, creation_access[i].open_mode,
|
||||||
|
@ -5527,7 +5529,7 @@ static void test_named_pipe_security(HANDLE token)
|
||||||
access = get_obj_access(file);
|
access = get_obj_access(file);
|
||||||
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
||||||
|
@ -5552,7 +5554,7 @@ static void test_named_pipe_security(HANDLE token)
|
||||||
access = get_obj_access(file);
|
access = get_obj_access(file);
|
||||||
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
||||||
|
@ -5600,7 +5602,7 @@ static void test_file_security(HANDLE token)
|
||||||
access = get_obj_access(file);
|
access = get_obj_access(file);
|
||||||
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
||||||
|
@ -5658,7 +5660,7 @@ todo_wine
|
||||||
access = get_obj_access(file);
|
access = get_obj_access(file);
|
||||||
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
ok(access == FILE_ALL_ACCESS, "expected FILE_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), file, GetCurrentProcess(), &dup,
|
||||||
|
@ -5742,7 +5744,7 @@ static void test_filemap_security(void)
|
||||||
SetFilePointer(file, 4096, NULL, FILE_BEGIN);
|
SetFilePointer(file, 4096, NULL, FILE_BEGIN);
|
||||||
SetEndOfFile(file);
|
SetEndOfFile(file);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(prot_map)/sizeof(prot_map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(prot_map); i++)
|
||||||
{
|
{
|
||||||
if (map[i].open_only) continue;
|
if (map[i].open_only) continue;
|
||||||
|
|
||||||
|
@ -5790,7 +5792,7 @@ static void test_filemap_security(void)
|
||||||
ok(access == (STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE),
|
ok(access == (STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE),
|
||||||
"expected STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE, got %#x\n", access);
|
"expected STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
if (map[i].open_only) continue;
|
if (map[i].open_only) continue;
|
||||||
|
|
||||||
|
@ -5813,7 +5815,7 @@ static void test_filemap_security(void)
|
||||||
"Wine Test Open Mapping");
|
"Wine Test Open Mapping");
|
||||||
ok(created_mapping != NULL, "CreateFileMapping failed with error %u\n", GetLastError());
|
ok(created_mapping != NULL, "CreateFileMapping failed with error %u\n", GetLastError());
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
if (!map[i].generic) continue;
|
if (!map[i].generic) continue;
|
||||||
|
|
||||||
|
@ -5851,7 +5853,7 @@ static void test_thread_security(void)
|
||||||
access = get_obj_access(thread);
|
access = get_obj_access(thread);
|
||||||
ok(access == THREAD_ALL_ACCESS_NT4 || access == THREAD_ALL_ACCESS_VISTA, "expected THREAD_ALL_ACCESS, got %#x\n", access);
|
ok(access == THREAD_ALL_ACCESS_NT4 || access == THREAD_ALL_ACCESS_VISTA, "expected THREAD_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), thread, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), thread, GetCurrentProcess(), &dup,
|
||||||
|
@ -5933,7 +5935,7 @@ static void test_process_access(void)
|
||||||
access = get_obj_access(process);
|
access = get_obj_access(process);
|
||||||
ok(access == PROCESS_ALL_ACCESS_NT4 || access == PROCESS_ALL_ACCESS_VISTA, "expected PROCESS_ALL_ACCESS, got %#x\n", access);
|
ok(access == PROCESS_ALL_ACCESS_NT4 || access == PROCESS_ALL_ACCESS_VISTA, "expected PROCESS_ALL_ACCESS, got %#x\n", access);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
|
for (i = 0; i < ARRAY_SIZE(map); i++)
|
||||||
{
|
{
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
ret = DuplicateHandle(GetCurrentProcess(), process, GetCurrentProcess(), &dup,
|
ret = DuplicateHandle(GetCurrentProcess(), process, GetCurrentProcess(), &dup,
|
||||||
|
|
Loading…
Reference in New Issue