netapi32: 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-09 20:59:17 +02:00 committed by Alexandre Julliard
parent 4341c4495f
commit 2f4f1399d1
3 changed files with 10 additions and 12 deletions

View File

@ -1095,8 +1095,7 @@ static UCHAR NetBTSend(void *adapt, void *sess, PNCB ncb)
wsaBufs[1].len = ncb->ncb_length; wsaBufs[1].len = ncb->ncb_length;
wsaBufs[1].buf = (char*)ncb->ncb_buffer; wsaBufs[1].buf = (char*)ncb->ncb_buffer;
r = WSASend(session->fd, wsaBufs, sizeof(wsaBufs) / sizeof(wsaBufs[0]), r = WSASend(session->fd, wsaBufs, ARRAY_SIZE(wsaBufs), &bytesSent, 0, NULL, NULL);
&bytesSent, 0, NULL, NULL);
if (r == SOCKET_ERROR) if (r == SOCKET_ERROR)
{ {
NetBIOSHangupSession(ncb); NetBIOSHangupSession(ncb);
@ -1523,10 +1522,9 @@ void NetBTInit(void)
char nsString[16]; char nsString[16];
DWORD size, ndx; DWORD size, ndx;
for (ndx = 0; ndx < sizeof(nsValueNames) / sizeof(nsValueNames[0]); for (ndx = 0; ndx < ARRAY_SIZE(nsValueNames); ndx++)
ndx++)
{ {
size = sizeof(nsString) / sizeof(char); size = ARRAY_SIZE(nsString);
if (RegQueryValueExA(hKey, nsValueNames[ndx], NULL, NULL, if (RegQueryValueExA(hKey, nsValueNames[ndx], NULL, NULL,
(LPBYTE)nsString, &size) == ERROR_SUCCESS) (LPBYTE)nsString, &size) == ERROR_SUCCESS)
{ {

View File

@ -923,7 +923,7 @@ static NET_API_STATUS wksta_getinfo( LMSTR servername, DWORD level, LPBYTE *buf
static BOOL NETAPI_IsLocalComputer( LMCSTR name ) static BOOL NETAPI_IsLocalComputer( LMCSTR name )
{ {
WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1]; WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = sizeof(buf) / sizeof(buf[0]); DWORD size = ARRAY_SIZE(buf);
BOOL ret; BOOL ret;
if (!name || !name[0]) return TRUE; if (!name || !name[0]) return TRUE;
@ -2360,7 +2360,7 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr,
{ {
NET_API_STATUS status; NET_API_STATUS status;
WCHAR user[UNLEN + 1]; WCHAR user[UNLEN + 1];
DWORD size, len = sizeof(user)/sizeof(user[0]); DWORD size, len = ARRAY_SIZE(user);
TRACE("(%s, %u, 0x%x, %p, %u, %p, %p, %p)\n", debugstr_w(servername), level, TRACE("(%s, %u, 0x%x, %p, %u, %p, %p, %p)\n", debugstr_w(servername), level,
filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle); filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
@ -3477,8 +3477,8 @@ DWORD WINAPI DavGetUNCFromHTTPPath(const WCHAR *http_path, WCHAR *buf, DWORD *bu
TRACE("(%s %p %p)\n", debugstr_w(http_path), buf, buflen); TRACE("(%s %p %p)\n", debugstr_w(http_path), buf, buflen);
while (*p && *p != ':') { p++; len++; }; while (*p && *p != ':') { p++; len++; };
if (len == sizeof(httpW)/sizeof(httpW[0]) && !memicmpW( http_path, httpW, len )) ssl = FALSE; if (len == ARRAY_SIZE(httpW) && !memicmpW( http_path, httpW, len )) ssl = FALSE;
else if (len == sizeof(httpsW)/sizeof(httpsW[0]) && !memicmpW( http_path, httpsW, len )) ssl = TRUE; else if (len == ARRAY_SIZE(httpsW) && !memicmpW( http_path, httpsW, len )) ssl = TRUE;
else return ERROR_INVALID_PARAMETER; else return ERROR_INVALID_PARAMETER;
if (p[0] != ':' || p[1] != '/' || p[2] != '/') return ERROR_INVALID_PARAMETER; if (p[0] != ':' || p[1] != '/' || p[2] != '/') return ERROR_INVALID_PARAMETER;
@ -3506,7 +3506,7 @@ DWORD WINAPI DavGetUNCFromHTTPPath(const WCHAR *http_path, WCHAR *buf, DWORD *bu
len = len_server + 2; /* \\ */ len = len_server + 2; /* \\ */
if (ssl) len += 4; /* @SSL */ if (ssl) len += 4; /* @SSL */
if (port) len += len_port + 1 /* @ */; if (port) len += len_port + 1 /* @ */;
len += sizeof(davrootW)/sizeof(davrootW[0]); len += ARRAY_SIZE(davrootW);
len += len_path + 1; /* nul */ len += len_path + 1; /* nul */
if (*buflen < len) if (*buflen < len)
@ -3531,7 +3531,7 @@ DWORD WINAPI DavGetUNCFromHTTPPath(const WCHAR *http_path, WCHAR *buf, DWORD *bu
buf += len_port; buf += len_port;
} }
memcpy( buf, davrootW, sizeof(davrootW) ); memcpy( buf, davrootW, sizeof(davrootW) );
buf += sizeof(davrootW)/sizeof(davrootW[0]); buf += ARRAY_SIZE(davrootW);
for (i = 0; i < len_path; i++) for (i = 0; i < len_path; i++)
{ {
if (path[i] == '/') *buf++ = '\\'; if (path[i] == '/') *buf++ = '\\';

View File

@ -135,7 +135,7 @@ BOOL NetBIOSRegisterTransport(ULONG id, NetBIOSTransport *transport)
TRACE(": transport 0x%08x, p %p\n", id, transport); TRACE(": transport 0x%08x, p %p\n", id, transport);
if (!transport) if (!transport)
ret = FALSE; ret = FALSE;
else if (gNumTransports >= sizeof(gTransports) / sizeof(gTransports[0])) else if (gNumTransports >= ARRAY_SIZE(gTransports))
{ {
FIXME("Too many transports %d\n", gNumTransports + 1); FIXME("Too many transports %d\n", gNumTransports + 1);
ret = FALSE; ret = FALSE;