winhttp: 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-25 19:35:02 +02:00 committed by Alexandre Julliard
parent 8c8ea309a4
commit 9c1298a0e5
4 changed files with 9 additions and 9 deletions

View File

@ -312,7 +312,7 @@ BOOL add_cookie_headers( request_t *request )
if (strstrW( request->path, cookie->path ) == request->path) if (strstrW( request->path, cookie->path ) == request->path)
{ {
const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '}; const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
int len, len_cookie = sizeof(cookieW) / sizeof(cookieW[0]), len_name = strlenW( cookie->name ); int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = strlenW( cookie->name );
WCHAR *header; WCHAR *header;
len = len_cookie + len_name; len = len_cookie + len_name;

View File

@ -397,7 +397,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
{conn->ssl_sizes.cbTrailer, SECBUFFER_STREAM_TRAILER, conn->ssl_buf+conn->ssl_sizes.cbHeader+size}, {conn->ssl_sizes.cbTrailer, SECBUFFER_STREAM_TRAILER, conn->ssl_buf+conn->ssl_sizes.cbHeader+size},
{0, SECBUFFER_EMPTY, NULL} {0, SECBUFFER_EMPTY, NULL}
}; };
SecBufferDesc buf_desc = {SECBUFFER_VERSION, sizeof(bufs)/sizeof(*bufs), bufs}; SecBufferDesc buf_desc = {SECBUFFER_VERSION, ARRAY_SIZE(bufs), bufs};
SECURITY_STATUS res; SECURITY_STATUS res;
memcpy(bufs[1].pvBuffer, msg, size); memcpy(bufs[1].pvBuffer, msg, size);
@ -443,7 +443,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *
{ {
const SIZE_T ssl_buf_size = conn->ssl_sizes.cbHeader+conn->ssl_sizes.cbMaximumMessage+conn->ssl_sizes.cbTrailer; const SIZE_T ssl_buf_size = conn->ssl_sizes.cbHeader+conn->ssl_sizes.cbMaximumMessage+conn->ssl_sizes.cbTrailer;
SecBuffer bufs[4]; SecBuffer bufs[4];
SecBufferDesc buf_desc = {SECBUFFER_VERSION, sizeof(bufs)/sizeof(*bufs), bufs}; SecBufferDesc buf_desc = {SECBUFFER_VERSION, ARRAY_SIZE(bufs), bufs};
SSIZE_T size, buf_len; SSIZE_T size, buf_len;
unsigned int i; unsigned int i;
SECURITY_STATUS res; SECURITY_STATUS res;
@ -499,7 +499,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *
} }
} while(res != SEC_E_OK); } while(res != SEC_E_OK);
for(i=0; i < sizeof(bufs)/sizeof(*bufs); i++) { for(i = 0; i < ARRAY_SIZE(bufs); i++) {
if(bufs[i].BufferType == SECBUFFER_DATA) { if(bufs[i].BufferType == SECBUFFER_DATA) {
size = min(buf_size, bufs[i].cbBuffer); size = min(buf_size, bufs[i].cbBuffer);
memcpy(buf, bufs[i].pvBuffer, size); memcpy(buf, bufs[i].pvBuffer, size);
@ -516,7 +516,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *
} }
} }
for(i=0; i < sizeof(bufs)/sizeof(*bufs); i++) { for(i = 0; i < ARRAY_SIZE(bufs); i++) {
if(bufs[i].BufferType == SECBUFFER_EXTRA) { if(bufs[i].BufferType == SECBUFFER_EXTRA) {
conn->extra_buf = heap_alloc(bufs[i].cbBuffer); conn->extra_buf = heap_alloc(bufs[i].cbBuffer);
if(!conn->extra_buf) if(!conn->extra_buf)

View File

@ -747,7 +747,7 @@ static BOOL query_headers( request_t *request, DWORD level, LPCWSTR name, LPVOID
return ret; return ret;
default: default:
if (attr >= sizeof(attribute_table)/sizeof(attribute_table[0]) || !attribute_table[attr]) if (attr >= ARRAY_SIZE(attribute_table) || !attribute_table[attr])
{ {
FIXME("attribute %u not implemented\n", attr); FIXME("attribute %u not implemented\n", attr);
return FALSE; return FALSE;
@ -3120,7 +3120,7 @@ void release_typelib(void)
{ {
unsigned i; unsigned i;
for (i = 0; i < sizeof(winhttp_typeinfo)/sizeof(*winhttp_typeinfo); i++) for (i = 0; i < ARRAY_SIZE(winhttp_typeinfo); i++)
if (winhttp_typeinfo[i]) if (winhttp_typeinfo[i])
ITypeInfo_Release(winhttp_typeinfo[i]); ITypeInfo_Release(winhttp_typeinfo[i]);
@ -3446,7 +3446,7 @@ static HRESULT WINAPI winhttp_request_Open(
goto error; goto error;
} }
len = sizeof(httpsW) / sizeof(WCHAR); len = ARRAY_SIZE( httpsW );
if (uc.dwSchemeLength == len && !memcmp( uc.lpszScheme, httpsW, len * sizeof(WCHAR) )) if (uc.dwSchemeLength == len && !memcmp( uc.lpszScheme, httpsW, len * sizeof(WCHAR) ))
{ {
flags |= WINHTTP_FLAG_SECURE; flags |= WINHTTP_FLAG_SECURE;

View File

@ -479,7 +479,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
if (uc->lpszHostName) if (uc->lpszHostName)
{ {
memcpy( url, twoslashW, sizeof(twoslashW) ); memcpy( url, twoslashW, sizeof(twoslashW) );
url += sizeof(twoslashW) / sizeof(twoslashW[0]); url += ARRAY_SIZE( twoslashW );
} }
if (uc->lpszUserName) if (uc->lpszUserName)
{ {