wbemprox: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-09-11 22:08:07 +02:00 committed by Alexandre Julliard
parent b29cdbd5f2
commit 3f4f96e088
5 changed files with 18 additions and 18 deletions

View File

@ -1782,7 +1782,7 @@ static WCHAR *get_file_version( const WCHAR *filename )
void *block;
WCHAR *ret;
if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
if (!(ret = heap_alloc( (4 * 5 + ARRAY_SIZE( fmtW )) * sizeof(WCHAR) ))) return NULL;
if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
{
heap_free( ret );
@ -2041,7 +2041,7 @@ static enum fill_status fill_diskdrive( struct table *table, const struct expr *
{
static const WCHAR fmtW[] =
{'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
WCHAR device_id[ARRAY_SIZE( fmtW ) + 10], root[] = {'A',':','\\',0};
struct record_diskdrive *rec;
UINT i, row = 0, offset = 0, index = 0, type;
UINT64 size = 1024 * 1024 * 1024;
@ -2208,7 +2208,7 @@ static enum fill_status fill_ip4routetable( struct table *table, const struct ex
static WCHAR *get_volumename( const WCHAR *root )
{
WCHAR buf[MAX_PATH + 1] = {0};
GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
GetVolumeInformationW( root, buf, ARRAY_SIZE( buf ), NULL, NULL, NULL, NULL, 0 );
return heap_strdupW( buf );
}
static WCHAR *get_volumeserialnumber( const WCHAR *root )
@ -2378,7 +2378,7 @@ static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
WCHAR buf[WS_NI_MAXHOST];
if (!addr) return NULL;
if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, ARRAY_SIZE( buf ), NULL,
0, WS_NI_NAMEREQD )) return NULL;
return heap_strdupW( buf );
}
@ -2400,7 +2400,7 @@ static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
}
for (gateway = list; gateway; gateway = gateway->Next)
{
buflen = sizeof(buf)/sizeof(buf[0]);
buflen = ARRAY_SIZE( buf );
if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength,
NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
{
@ -2432,7 +2432,7 @@ static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *li
}
for (server = list; server; server = server->Next)
{
buflen = sizeof(buf)/sizeof(buf[0]);
buflen = ARRAY_SIZE( buf );
if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength,
NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
{
@ -2465,7 +2465,7 @@ static struct array *get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
}
for (address = list; address; address = address->Next)
{
buflen = sizeof(buf)/sizeof(buf[0]);
buflen = ARRAY_SIZE( buf );
if (WSAAddressToStringW( address->Address.lpSockaddr, address->Address.iSockaddrLength,
NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
{
@ -2501,7 +2501,7 @@ static struct array *get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
{
WCHAR buf[INET_ADDRSTRLEN];
SOCKADDR_IN addr;
ULONG buflen = sizeof(buf)/sizeof(buf[0]);
ULONG buflen = ARRAY_SIZE( buf );
memset( &addr, 0, sizeof(addr) );
addr.sin_family = WS_AF_INET;
@ -3058,7 +3058,7 @@ static WCHAR *get_oscaption( OSVERSIONINFOEXW *ver )
{'8','.','1',' ','P','r','o',0};
static const WCHAR win10W[] =
{'1','0',' ','P','r','o',0};
int len = sizeof(windowsW)/sizeof(windowsW[0]);
int len = ARRAY_SIZE( windowsW );
WCHAR *ret;
if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(win2003W) ))) return NULL;
@ -3240,7 +3240,7 @@ static enum fill_status fill_service( struct table *table, const struct expr *co
ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
SERVICE_STATUS_PROCESS *status;
WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
DWORD len = ARRAY_SIZE( sysnameW );
UINT i, row = 0, offset = 0, size = 256, needed, count;
enum fill_status fill_status = FILL_STATUS_FAILED;
BOOL ret;

View File

@ -582,7 +582,7 @@ static BSTR get_body_text( const struct table *table, UINT row, UINT *len )
{
if ((value = get_value_bstr( table, row, i )))
{
*len += sizeof(fmtW) / sizeof(fmtW[0]);
*len += ARRAY_SIZE( fmtW );
*len += strlenW( table->columns[i].name );
*len += SysStringLen( value );
SysFreeString( value );
@ -608,7 +608,7 @@ static BSTR get_object_text( const struct view *view, UINT index )
UINT len, len_body, row = view->result[index];
BSTR ret, body;
len = sizeof(fmtW) / sizeof(fmtW[0]);
len = ARRAY_SIZE( fmtW );
len += strlenW( view->table->name );
if (!(body = get_body_text( view->table, row, &len_body ))) return NULL;
len += len_body;

View File

@ -507,7 +507,7 @@ static BOOL is_system_prop( const WCHAR *name )
static BSTR build_servername( const struct view *view )
{
WCHAR server[MAX_COMPUTERNAME_LENGTH + 1], *p;
DWORD len = sizeof(server)/sizeof(server[0]);
DWORD len = ARRAY_SIZE( server );
if (view->proplist) return NULL;

View File

@ -82,7 +82,7 @@ static HRESULT enum_key( HKEY root, const WCHAR *subkey, VARIANT *names, VARIANT
HRESULT hr = S_OK;
WCHAR buf[256];
BSTR *strings, *tmp;
DWORD count = 2, len = sizeof(buf)/sizeof(buf[0]);
DWORD count = 2, len = ARRAY_SIZE( buf );
LONG res, i = 0;
TRACE("%p, %s\n", root, debugstr_w(subkey));

View File

@ -91,7 +91,7 @@ static BOOL is_local_machine( const WCHAR *server )
static const WCHAR dotW[] = {'.',0};
static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0};
WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 1];
DWORD len = sizeof(buffer) / sizeof(buffer[0]);
DWORD len = ARRAY_SIZE( buffer );
if (!server || !strcmpW( server, dotW ) || !strcmpiW( server, localhostW )) return TRUE;
if (GetComputerNameW( buffer, &len ) && !strcmpiW( server, buffer )) return TRUE;
@ -133,7 +133,7 @@ static HRESULT parse_resource( const WCHAR *resource, WCHAR **server, WCHAR **na
p = q;
while (*q && *q != '\\' && *q != '/') q++;
len = q - p;
if (len >= sizeof(rootW) / sizeof(rootW[0]) && memicmpW( rootW, p, len )) goto done;
if (len >= ARRAY_SIZE( rootW ) && memicmpW( rootW, p, len )) goto done;
if (!*q)
{
hr = S_OK;
@ -141,8 +141,8 @@ static HRESULT parse_resource( const WCHAR *resource, WCHAR **server, WCHAR **na
}
q++;
len = strlenW( q );
if ((len != sizeof(cimv2W) / sizeof(cimv2W[0]) || memicmpW( q, cimv2W, len )) &&
(len != sizeof(defaultW) / sizeof(defaultW[0]) || memicmpW( q, defaultW, len )))
if ((len != ARRAY_SIZE( cimv2W ) || memicmpW( q, cimv2W, len )) &&
(len != ARRAY_SIZE( defaultW ) || memicmpW( q, defaultW, len )))
goto done;
if (!(*namespace = heap_alloc( (len + 1) * sizeof(WCHAR) ))) hr = E_OUTOFMEMORY;
else