advapi32: 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
ae5d0b2229
commit
89e2cf6b2b
|
@ -25,6 +25,8 @@
|
|||
#include "winnls.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
const char * debugstr_sid(PSID sid) DECLSPEC_HIDDEN;
|
||||
BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName) DECLSPEC_HIDDEN;
|
||||
BOOL ADVAPI_GetComputerSid(PSID sid) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -248,7 +248,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require
|
|||
SecKeychainAttributeList *attr_list;
|
||||
UInt32 info_tags[] = { kSecServiceItemAttr, kSecAccountItemAttr,
|
||||
kSecCommentItemAttr, kSecCreationDateItemAttr };
|
||||
info.count = sizeof(info_tags)/sizeof(info_tags[0]);
|
||||
info.count = ARRAY_SIZE(info_tags);
|
||||
info.tag = info_tags;
|
||||
info.format = NULL;
|
||||
status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, &cred_blob_len, &cred_blob);
|
||||
|
@ -641,12 +641,12 @@ static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type)
|
|||
if (type == CRED_TYPE_GENERIC)
|
||||
{
|
||||
prefix = wszGenericPrefix;
|
||||
len += sizeof(wszGenericPrefix)/sizeof(wszGenericPrefix[0]);
|
||||
len += ARRAY_SIZE(wszGenericPrefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = wszDomPasswdPrefix;
|
||||
len += sizeof(wszDomPasswdPrefix)/sizeof(wszDomPasswdPrefix[0]);
|
||||
len += ARRAY_SIZE(wszDomPasswdPrefix);
|
||||
}
|
||||
|
||||
key_name = heap_alloc(len * sizeof(WCHAR));
|
||||
|
@ -792,7 +792,7 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW *credentials
|
|||
UInt32 info_tags[] = { kSecServiceItemAttr };
|
||||
BOOL match;
|
||||
|
||||
info.count = sizeof(info_tags)/sizeof(info_tags[0]);
|
||||
info.count = ARRAY_SIZE(info_tags);
|
||||
info.tag = info_tags;
|
||||
info.format = NULL;
|
||||
status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL);
|
||||
|
@ -851,7 +851,7 @@ static DWORD mac_delete_credential(LPCWSTR TargetName)
|
|||
UInt32 info_tags[] = { kSecServiceItemAttr };
|
||||
LPWSTR target_name;
|
||||
INT str_len;
|
||||
info.count = sizeof(info_tags)/sizeof(info_tags[0]);
|
||||
info.count = ARRAY_SIZE(info_tags);
|
||||
info.tag = info_tags;
|
||||
info.format = NULL;
|
||||
status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL);
|
||||
|
@ -1439,7 +1439,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW
|
|||
UInt32 info_tags[] = { kSecServiceItemAttr };
|
||||
LPWSTR target_name;
|
||||
INT str_len;
|
||||
info.count = sizeof(info_tags)/sizeof(info_tags[0]);
|
||||
info.count = ARRAY_SIZE(info_tags);
|
||||
info.tag = info_tags;
|
||||
info.format = NULL;
|
||||
status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL);
|
||||
|
|
|
@ -84,9 +84,7 @@ static const WCHAR * const root_key_names[] =
|
|||
name_DYN_DATA
|
||||
};
|
||||
|
||||
#define NB_SPECIAL_ROOT_KEYS (sizeof(root_key_names)/sizeof(root_key_names[0]))
|
||||
|
||||
static HKEY special_root_keys[NB_SPECIAL_ROOT_KEYS];
|
||||
static HKEY special_root_keys[ARRAY_SIZE(root_key_names)];
|
||||
static BOOL hkcu_cache_disabled;
|
||||
|
||||
static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
|
||||
|
|
|
@ -964,7 +964,7 @@ CreateWellKnownSid( WELL_KNOWN_SID_TYPE WellKnownSidType,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownSids); i++) {
|
||||
if (WellKnownSids[i].Type == WellKnownSidType) {
|
||||
DWORD length = GetSidLengthRequired(WellKnownSids[i].Sid.SubAuthorityCount);
|
||||
|
||||
|
@ -991,7 +991,7 @@ CreateWellKnownSid( WELL_KNOWN_SID_TYPE WellKnownSidType,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownRids); i++)
|
||||
if (WellKnownRids[i].Type == WellKnownSidType) {
|
||||
UCHAR domain_subauth = *GetSidSubAuthorityCount(DomainSid);
|
||||
DWORD domain_sid_length = GetSidLengthRequired(domain_subauth);
|
||||
|
@ -1028,7 +1028,7 @@ IsWellKnownSid( PSID pSid, WELL_KNOWN_SID_TYPE WellKnownSidType )
|
|||
unsigned int i;
|
||||
TRACE("(%s, %d)\n", debugstr_sid(pSid), WellKnownSidType);
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownSids); i++)
|
||||
if (WellKnownSids[i].Type == WellKnownSidType)
|
||||
if (EqualSid(pSid, (PSID)&(WellKnownSids[i].Sid.Revision)))
|
||||
return TRUE;
|
||||
|
@ -2252,7 +2252,7 @@ LookupAccountSidW(
|
|||
/* check the well known SIDs first */
|
||||
for (i = 0; i <= WinAccountProtectedUsersSid; i++) {
|
||||
if (IsWellKnownSid(sid, i)) {
|
||||
for (j = 0; j < (sizeof(ACCOUNT_SIDS) / sizeof(ACCOUNT_SIDS[0])); j++) {
|
||||
for (j = 0; j < ARRAY_SIZE(ACCOUNT_SIDS); j++) {
|
||||
if (ACCOUNT_SIDS[j].type == i) {
|
||||
ac = ACCOUNT_SIDS[j].account;
|
||||
dm = ACCOUNT_SIDS[j].domain;
|
||||
|
@ -2937,7 +2937,7 @@ BOOL lookup_local_wellknown_name( const LSA_UNICODE_STRING *account_and_domain,
|
|||
*handled = FALSE;
|
||||
split_domain_account( account_and_domain, &account, &domain );
|
||||
|
||||
for (i = 0; i < sizeof(ACCOUNT_SIDS) / sizeof(ACCOUNT_SIDS[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(ACCOUNT_SIDS); i++)
|
||||
{
|
||||
/* check domain first */
|
||||
if (domain.Buffer && !match_domain( i, &domain )) continue;
|
||||
|
@ -4926,7 +4926,7 @@ static BOOL DumpSidNumeric(PSID psid, WCHAR **pwptr, ULONG *plen)
|
|||
static BOOL DumpSid(PSID psid, WCHAR **pwptr, ULONG *plen)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < sizeof(WellKnownSids) / sizeof(WellKnownSids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownSids); i++)
|
||||
{
|
||||
if (WellKnownSids[i].wstr[0] && EqualSid(psid, (PSID)&(WellKnownSids[i].Sid.Revision)))
|
||||
{
|
||||
|
@ -4983,7 +4983,7 @@ static void DumpRights(DWORD mask, WCHAR **pwptr, ULONG *plen)
|
|||
return;
|
||||
|
||||
/* first check if the right have name */
|
||||
for (i = 0; i < sizeof(AceRights)/sizeof(AceRights[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(AceRights); i++)
|
||||
{
|
||||
if (AceRights[i].wstr == NULL)
|
||||
break;
|
||||
|
@ -5633,11 +5633,11 @@ static DWORD ComputeStringSidSize(LPCWSTR StringSid)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownSids); i++)
|
||||
if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
|
||||
return GetSidLengthRequired(WellKnownSids[i].Sid.SubAuthorityCount);
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownRids); i++)
|
||||
if (!strncmpW(WellKnownRids[i].wstr, StringSid, 2))
|
||||
{
|
||||
MAX_SID local;
|
||||
|
@ -5740,7 +5740,7 @@ static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
|
|||
unsigned int i;
|
||||
pisid->Revision = SDDL_REVISION;
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownSids); i++)
|
||||
if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
|
||||
{
|
||||
DWORD j;
|
||||
|
@ -5751,7 +5751,7 @@ static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
|
|||
bret = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(WellKnownRids); i++)
|
||||
if (!strncmpW(WellKnownRids[i].wstr, StringSid, 2))
|
||||
{
|
||||
ADVAPI_GetComputerSid(pisid);
|
||||
|
|
Loading…
Reference in New Issue