pdh: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-07-11 22:06:14 +02:00 committed by Alexandre Julliard
parent 312cad708b
commit acb879c9d2
1 changed files with 6 additions and 6 deletions

View File

@ -210,7 +210,7 @@ static const struct source counter_sources[] =
static BOOL is_local_machine( const WCHAR *name, DWORD len ) static BOOL is_local_machine( const WCHAR *name, DWORD len )
{ {
WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1]; WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD buflen = sizeof(buf) / sizeof(buf[0]); DWORD buflen = ARRAY_SIZE(buf);
if (!GetComputerNameW( buf, &buflen )) return FALSE; if (!GetComputerNameW( buf, &buflen )) return FALSE;
return len == buflen && !memicmpW( name, buf, buflen ); return len == buflen && !memicmpW( name, buf, buflen );
@ -274,7 +274,7 @@ PDH_STATUS WINAPI PdhAddCounterW( PDH_HQUERY hquery, LPCWSTR path,
} }
*hcounter = NULL; *hcounter = NULL;
for (i = 0; i < sizeof(counter_sources) / sizeof(counter_sources[0]); i++) for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
{ {
if (pdh_match_path( counter_sources[i].path, path )) if (pdh_match_path( counter_sources[i].path, path ))
{ {
@ -867,7 +867,7 @@ PDH_STATUS WINAPI PdhLookupPerfIndexByNameW( LPCWSTR machine, LPCWSTR name, LPDW
FIXME("remote machine not supported\n"); FIXME("remote machine not supported\n");
return PDH_CSTATUS_NO_MACHINE; return PDH_CSTATUS_NO_MACHINE;
} }
for (i = 0; i < sizeof(counter_sources) / sizeof(counter_sources[0]); i++) for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
{ {
if (pdh_match_path( counter_sources[i].path, name )) if (pdh_match_path( counter_sources[i].path, name ))
{ {
@ -886,7 +886,7 @@ PDH_STATUS WINAPI PdhLookupPerfNameByIndexA( LPCSTR machine, DWORD index, LPSTR
PDH_STATUS ret; PDH_STATUS ret;
WCHAR *machineW = NULL; WCHAR *machineW = NULL;
WCHAR bufferW[PDH_MAX_COUNTER_NAME]; WCHAR bufferW[PDH_MAX_COUNTER_NAME];
DWORD sizeW = sizeof(bufferW) / sizeof(WCHAR); DWORD sizeW = ARRAY_SIZE(bufferW);
TRACE("%s %d %p %p\n", debugstr_a(machine), index, buffer, size); TRACE("%s %d %p %p\n", debugstr_a(machine), index, buffer, size);
@ -925,7 +925,7 @@ PDH_STATUS WINAPI PdhLookupPerfNameByIndexW( LPCWSTR machine, DWORD index, LPWST
if (!buffer || !size) return PDH_INVALID_ARGUMENT; if (!buffer || !size) return PDH_INVALID_ARGUMENT;
if (!index) return ERROR_SUCCESS; if (!index) return ERROR_SUCCESS;
for (i = 0; i < sizeof(counter_sources) / sizeof(counter_sources[0]); i++) for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
{ {
if (counter_sources[i].index == index) if (counter_sources[i].index == index)
{ {
@ -1077,7 +1077,7 @@ PDH_STATUS WINAPI PdhValidatePathW( LPCWSTR path )
if ((ret = validate_path( path ))) return ret; if ((ret = validate_path( path ))) return ret;
for (i = 0; i < sizeof(counter_sources) / sizeof(counter_sources[0]); i++) for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
if (pdh_match_path( counter_sources[i].path, path )) return ERROR_SUCCESS; if (pdh_match_path( counter_sources[i].path, path )) return ERROR_SUCCESS;
return PDH_CSTATUS_NO_COUNTER; return PDH_CSTATUS_NO_COUNTER;