Michael Stefaniuc : wbemprox: Use the ARRAY_SIZE() macro.
Alexandre Julliard
julliard at winehq.org
Wed Sep 12 16:40:34 CDT 2018
Module: wine
Branch: master
Commit: 3f4f96e088c5c42d932be3d65253480d3484ffec
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3f4f96e088c5c42d932be3d65253480d3484ffec
Author: Michael Stefaniuc <mstefani at winehq.org>
Date: Tue Sep 11 22:08:07 2018 +0200
wbemprox: Use the ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wbemprox/builtin.c | 20 ++++++++++----------
dlls/wbemprox/class.c | 4 ++--
dlls/wbemprox/query.c | 2 +-
dlls/wbemprox/reg.c | 2 +-
dlls/wbemprox/wbemlocator.c | 8 ++++----
5 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 9fe22d0..a695e7c 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -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;
diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index 27229bd..92c110f 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -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;
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index 76f5caa..8a51266 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -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;
diff --git a/dlls/wbemprox/reg.c b/dlls/wbemprox/reg.c
index 9232db7..79440da 100644
--- a/dlls/wbemprox/reg.c
+++ b/dlls/wbemprox/reg.c
@@ -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));
diff --git a/dlls/wbemprox/wbemlocator.c b/dlls/wbemprox/wbemlocator.c
index 6ed0aed..fe26a87 100644
--- a/dlls/wbemprox/wbemlocator.c
+++ b/dlls/wbemprox/wbemlocator.c
@@ -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
More information about the wine-cvs
mailing list