webservices: 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:08 +02:00 committed by Alexandre Julliard
parent 3f4f96e088
commit 9d52b5f847
10 changed files with 28 additions and 28 deletions

View File

@ -236,14 +236,14 @@ struct channel
ULONG read_buflen; ULONG read_buflen;
ULONG read_size; ULONG read_size;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(channel_props)/sizeof(channel_props[0])]; struct prop prop[ARRAY_SIZE( channel_props )];
}; };
#define CHANNEL_MAGIC (('C' << 24) | ('H' << 16) | ('A' << 8) | 'N') #define CHANNEL_MAGIC (('C' << 24) | ('H' << 16) | ('A' << 8) | 'N')
static struct channel *alloc_channel(void) static struct channel *alloc_channel(void)
{ {
static const ULONG count = sizeof(channel_props)/sizeof(channel_props[0]); static const ULONG count = ARRAY_SIZE( channel_props );
struct channel *ret; struct channel *ret;
ULONG size = sizeof(*ret) + prop_size( channel_props, count ); ULONG size = sizeof(*ret) + prop_size( channel_props, count );

View File

@ -42,14 +42,14 @@ struct error
ULONG magic; ULONG magic;
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(error_props)/sizeof(error_props[0])]; struct prop prop[ARRAY_SIZE( error_props )];
}; };
#define ERROR_MAGIC (('E' << 24) | ('R' << 16) | ('R' << 8) | 'O') #define ERROR_MAGIC (('E' << 24) | ('R' << 16) | ('R' << 8) | 'O')
static struct error *alloc_error(void) static struct error *alloc_error(void)
{ {
static const ULONG count = sizeof(error_props)/sizeof(error_props[0]); static const ULONG count = ARRAY_SIZE( error_props );
struct error *ret; struct error *ret;
ULONG size = sizeof(*ret) + prop_size( error_props, count ); ULONG size = sizeof(*ret) + prop_size( error_props, count );

View File

@ -46,7 +46,7 @@ struct heap
SIZE_T max_size; SIZE_T max_size;
SIZE_T allocated; SIZE_T allocated;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(heap_props)/sizeof(heap_props[0])]; struct prop prop[ARRAY_SIZE( heap_props )];
}; };
#define HEAP_MAGIC (('H' << 24) | ('E' << 16) | ('A' << 8) | 'P') #define HEAP_MAGIC (('H' << 24) | ('E' << 16) | ('A' << 8) | 'P')
@ -177,7 +177,7 @@ HRESULT WINAPI WsAlloc( WS_HEAP *handle, SIZE_T size, void **ptr, WS_ERROR *erro
static struct heap *alloc_heap(void) static struct heap *alloc_heap(void)
{ {
static const ULONG count = sizeof(heap_props)/sizeof(heap_props[0]); static const ULONG count = ARRAY_SIZE( heap_props );
struct heap *ret; struct heap *ret;
ULONG size = sizeof(*ret) + prop_size( heap_props, count ); ULONG size = sizeof(*ret) + prop_size( heap_props, count );

View File

@ -113,14 +113,14 @@ struct listener
} udp; } udp;
} u; } u;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(listener_props)/sizeof(listener_props[0])]; struct prop prop[ARRAY_SIZE( listener_props )];
}; };
#define LISTENER_MAGIC (('L' << 24) | ('I' << 16) | ('S' << 8) | 'T') #define LISTENER_MAGIC (('L' << 24) | ('I' << 16) | ('S' << 8) | 'T')
static struct listener *alloc_listener(void) static struct listener *alloc_listener(void)
{ {
static const ULONG count = sizeof(listener_props)/sizeof(listener_props[0]); static const ULONG count = ARRAY_SIZE( listener_props );
struct listener *ret; struct listener *ret;
ULONG size = sizeof(*ret) + prop_size( listener_props, count ); ULONG size = sizeof(*ret) + prop_size( listener_props, count );

View File

@ -83,7 +83,7 @@ struct msg
WS_PROXY_MESSAGE_CALLBACK_CONTEXT ctx_send; WS_PROXY_MESSAGE_CALLBACK_CONTEXT ctx_send;
WS_PROXY_MESSAGE_CALLBACK_CONTEXT ctx_receive; WS_PROXY_MESSAGE_CALLBACK_CONTEXT ctx_receive;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(msg_props)/sizeof(msg_props[0])]; struct prop prop[ARRAY_SIZE( msg_props )];
}; };
#define MSG_MAGIC (('M' << 24) | ('E' << 16) | ('S' << 8) | 'S') #define MSG_MAGIC (('M' << 24) | ('E' << 16) | ('S' << 8) | 'S')
@ -91,7 +91,7 @@ struct msg
static struct msg *alloc_msg(void) static struct msg *alloc_msg(void)
{ {
static const ULONG count = sizeof(msg_props)/sizeof(msg_props[0]); static const ULONG count = ARRAY_SIZE( msg_props );
struct msg *ret; struct msg *ret;
ULONG size = sizeof(*ret) + prop_size( msg_props, count ); ULONG size = sizeof(*ret) + prop_size( msg_props, count );
@ -1785,7 +1785,7 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
case WS_ENVELOPE_VERSION_SOAP_1_2: case WS_ENVELOPE_VERSION_SOAP_1_2:
{ {
static const WCHAR actionW[] = {'a','c','t','i','o','n','=','"'}; static const WCHAR actionW[] = {'a','c','t','i','o','n','=','"'};
ULONG len_action = sizeof(actionW)/sizeof(actionW[0]); ULONG len_action = ARRAY_SIZE( actionW );
if (!(len = MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, NULL, 0 ))) if (!(len = MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, NULL, 0 )))
break; break;

View File

@ -48,14 +48,14 @@ struct proxy
WS_SERVICE_PROXY_STATE state; WS_SERVICE_PROXY_STATE state;
WS_CHANNEL *channel; WS_CHANNEL *channel;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(proxy_props)/sizeof(proxy_props[0])]; struct prop prop[ARRAY_SIZE( proxy_props )];
}; };
#define PROXY_MAGIC (('P' << 24) | ('R' << 16) | ('O' << 8) | 'X') #define PROXY_MAGIC (('P' << 24) | ('R' << 16) | ('O' << 8) | 'X')
static struct proxy *alloc_proxy(void) static struct proxy *alloc_proxy(void)
{ {
static const ULONG count = sizeof(proxy_props)/sizeof(proxy_props[0]); static const ULONG count = ARRAY_SIZE( proxy_props );
struct proxy *ret; struct proxy *ret;
ULONG size = sizeof(*ret) + prop_size( proxy_props, count ); ULONG size = sizeof(*ret) + prop_size( proxy_props, count );

View File

@ -397,14 +397,14 @@ struct reader
const WS_XML_DICTIONARY *dict_static; const WS_XML_DICTIONARY *dict_static;
WS_XML_DICTIONARY *dict; WS_XML_DICTIONARY *dict;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(reader_props)/sizeof(reader_props[0])]; struct prop prop[ARRAY_SIZE( reader_props )];
}; };
#define READER_MAGIC (('R' << 24) | ('E' << 16) | ('A' << 8) | 'D') #define READER_MAGIC (('R' << 24) | ('E' << 16) | ('A' << 8) | 'D')
static struct reader *alloc_reader(void) static struct reader *alloc_reader(void)
{ {
static const ULONG count = sizeof(reader_props)/sizeof(reader_props[0]); static const ULONG count = ARRAY_SIZE( reader_props );
struct reader *ret; struct reader *ret;
ULONG size = sizeof(*ret) + prop_size( reader_props, count ); ULONG size = sizeof(*ret) + prop_size( reader_props, count );

View File

@ -791,7 +791,7 @@ static const ULONG dict_sorted[] =
const struct dictionary dict_builtin_static = const struct dictionary dict_builtin_static =
{ {
{{0xf93578f8,0x5852,0x4eb7,{0xa6,0xfc,0xe7,0x2b,0xb7,0x1d,0xb6,0x22}}, {{0xf93578f8,0x5852,0x4eb7,{0xa6,0xfc,0xe7,0x2b,0xb7,0x1d,0xb6,0x22}},
(WS_XML_STRING *)dict_strings, sizeof(dict_strings)/sizeof(dict_strings[0]), TRUE}, (WS_XML_STRING *)dict_strings, ARRAY_SIZE( dict_strings ), TRUE},
(ULONG *)dict_sorted (ULONG *)dict_sorted
}; };

View File

@ -39,19 +39,19 @@ static const WCHAR netpipe[] = {'n','e','t','.','p','i','p','e'};
static WS_URL_SCHEME_TYPE scheme_type( const WCHAR *str, ULONG len ) static WS_URL_SCHEME_TYPE scheme_type( const WCHAR *str, ULONG len )
{ {
if (len == sizeof(http)/sizeof(http[0]) && !memicmpW( str, http, sizeof(http)/sizeof(http[0]) )) if (len == ARRAY_SIZE( http ) && !memicmpW( str, http, ARRAY_SIZE( http )))
return WS_URL_HTTP_SCHEME_TYPE; return WS_URL_HTTP_SCHEME_TYPE;
if (len == sizeof(https)/sizeof(https[0]) && !memicmpW( str, https, sizeof(https)/sizeof(https[0]) )) if (len == ARRAY_SIZE( https ) && !memicmpW( str, https, ARRAY_SIZE( https )))
return WS_URL_HTTPS_SCHEME_TYPE; return WS_URL_HTTPS_SCHEME_TYPE;
if (len == sizeof(nettcp)/sizeof(nettcp[0]) && !memicmpW( str, nettcp, sizeof(nettcp)/sizeof(nettcp[0]) )) if (len == ARRAY_SIZE( nettcp ) && !memicmpW( str, nettcp, ARRAY_SIZE( nettcp )))
return WS_URL_NETTCP_SCHEME_TYPE; return WS_URL_NETTCP_SCHEME_TYPE;
if (len == sizeof(soapudp)/sizeof(soapudp[0]) && !memicmpW( str, soapudp, sizeof(soapudp)/sizeof(soapudp[0]) )) if (len == ARRAY_SIZE( soapudp ) && !memicmpW( str, soapudp, ARRAY_SIZE( soapudp )))
return WS_URL_SOAPUDP_SCHEME_TYPE; return WS_URL_SOAPUDP_SCHEME_TYPE;
if (len == sizeof(netpipe)/sizeof(netpipe[0]) && !memicmpW( str, netpipe, sizeof(netpipe)/sizeof(netpipe[0]) )) if (len == ARRAY_SIZE( netpipe ) && !memicmpW( str, netpipe, ARRAY_SIZE( netpipe )))
return WS_URL_NETPIPE_SCHEME_TYPE; return WS_URL_NETPIPE_SCHEME_TYPE;
return ~0u; return ~0u;
@ -271,23 +271,23 @@ static const WCHAR *scheme_str( WS_URL_SCHEME_TYPE scheme, ULONG *len )
switch (scheme) switch (scheme)
{ {
case WS_URL_HTTP_SCHEME_TYPE: case WS_URL_HTTP_SCHEME_TYPE:
*len = sizeof(http)/sizeof(http[0]); *len = ARRAY_SIZE( http );
return http; return http;
case WS_URL_HTTPS_SCHEME_TYPE: case WS_URL_HTTPS_SCHEME_TYPE:
*len = sizeof(https)/sizeof(https[0]); *len = ARRAY_SIZE( https );
return https; return https;
case WS_URL_NETTCP_SCHEME_TYPE: case WS_URL_NETTCP_SCHEME_TYPE:
*len = sizeof(nettcp)/sizeof(nettcp[0]); *len = ARRAY_SIZE( nettcp );
return nettcp; return nettcp;
case WS_URL_SOAPUDP_SCHEME_TYPE: case WS_URL_SOAPUDP_SCHEME_TYPE:
*len = sizeof(soapudp)/sizeof(soapudp[0]); *len = ARRAY_SIZE( soapudp );
return soapudp; return soapudp;
case WS_URL_NETPIPE_SCHEME_TYPE: case WS_URL_NETPIPE_SCHEME_TYPE:
*len = sizeof(netpipe)/sizeof(netpipe[0]); *len = ARRAY_SIZE( netpipe );
return netpipe; return netpipe;
default: default:

View File

@ -92,14 +92,14 @@ struct writer
WS_DYNAMIC_STRING_CALLBACK dict_cb; WS_DYNAMIC_STRING_CALLBACK dict_cb;
void *dict_cb_state; void *dict_cb_state;
ULONG prop_count; ULONG prop_count;
struct prop prop[sizeof(writer_props)/sizeof(writer_props[0])]; struct prop prop[ARRAY_SIZE( writer_props )];
}; };
#define WRITER_MAGIC (('W' << 24) | ('R' << 16) | ('I' << 8) | 'T') #define WRITER_MAGIC (('W' << 24) | ('R' << 16) | ('I' << 8) | 'T')
static struct writer *alloc_writer(void) static struct writer *alloc_writer(void)
{ {
static const ULONG count = sizeof(writer_props)/sizeof(writer_props[0]); static const ULONG count = ARRAY_SIZE( writer_props );
struct writer *ret; struct writer *ret;
ULONG size = sizeof(*ret) + prop_size( writer_props, count ); ULONG size = sizeof(*ret) + prop_size( writer_props, count );