From 2f4f1399d17318a8be5c449a25e4994c9e9cbc35 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Mon, 9 Jul 2018 20:59:17 +0200 Subject: [PATCH] netapi32: Use the ARRAY_SIZE() macro. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- dlls/netapi32/nbt.c | 8 +++----- dlls/netapi32/netapi32.c | 12 ++++++------ dlls/netapi32/netbios.c | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dlls/netapi32/nbt.c b/dlls/netapi32/nbt.c index 207bd664255..48166303346 100644 --- a/dlls/netapi32/nbt.c +++ b/dlls/netapi32/nbt.c @@ -1095,8 +1095,7 @@ static UCHAR NetBTSend(void *adapt, void *sess, PNCB ncb) wsaBufs[1].len = ncb->ncb_length; wsaBufs[1].buf = (char*)ncb->ncb_buffer; - r = WSASend(session->fd, wsaBufs, sizeof(wsaBufs) / sizeof(wsaBufs[0]), - &bytesSent, 0, NULL, NULL); + r = WSASend(session->fd, wsaBufs, ARRAY_SIZE(wsaBufs), &bytesSent, 0, NULL, NULL); if (r == SOCKET_ERROR) { NetBIOSHangupSession(ncb); @@ -1523,10 +1522,9 @@ void NetBTInit(void) char nsString[16]; DWORD size, ndx; - for (ndx = 0; ndx < sizeof(nsValueNames) / sizeof(nsValueNames[0]); - ndx++) + for (ndx = 0; ndx < ARRAY_SIZE(nsValueNames); ndx++) { - size = sizeof(nsString) / sizeof(char); + size = ARRAY_SIZE(nsString); if (RegQueryValueExA(hKey, nsValueNames[ndx], NULL, NULL, (LPBYTE)nsString, &size) == ERROR_SUCCESS) { diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c index ff57c223b4f..afeada6f1e8 100644 --- a/dlls/netapi32/netapi32.c +++ b/dlls/netapi32/netapi32.c @@ -923,7 +923,7 @@ static NET_API_STATUS wksta_getinfo( LMSTR servername, DWORD level, LPBYTE *buf static BOOL NETAPI_IsLocalComputer( LMCSTR name ) { WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD size = sizeof(buf) / sizeof(buf[0]); + DWORD size = ARRAY_SIZE(buf); BOOL ret; if (!name || !name[0]) return TRUE; @@ -2360,7 +2360,7 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr, { NET_API_STATUS status; 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, 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); while (*p && *p != ':') { p++; len++; }; - if (len == sizeof(httpW)/sizeof(httpW[0]) && !memicmpW( http_path, httpW, len )) ssl = FALSE; - else if (len == sizeof(httpsW)/sizeof(httpsW[0]) && !memicmpW( http_path, httpsW, len )) ssl = TRUE; + if (len == ARRAY_SIZE(httpW) && !memicmpW( http_path, httpW, len )) ssl = FALSE; + else if (len == ARRAY_SIZE(httpsW) && !memicmpW( http_path, httpsW, len )) ssl = TRUE; else 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; /* \\ */ if (ssl) len += 4; /* @SSL */ if (port) len += len_port + 1 /* @ */; - len += sizeof(davrootW)/sizeof(davrootW[0]); + len += ARRAY_SIZE(davrootW); len += len_path + 1; /* nul */ if (*buflen < len) @@ -3531,7 +3531,7 @@ DWORD WINAPI DavGetUNCFromHTTPPath(const WCHAR *http_path, WCHAR *buf, DWORD *bu buf += len_port; } memcpy( buf, davrootW, sizeof(davrootW) ); - buf += sizeof(davrootW)/sizeof(davrootW[0]); + buf += ARRAY_SIZE(davrootW); for (i = 0; i < len_path; i++) { if (path[i] == '/') *buf++ = '\\'; diff --git a/dlls/netapi32/netbios.c b/dlls/netapi32/netbios.c index e16c5dcc4fc..0d2bb0e012d 100644 --- a/dlls/netapi32/netbios.c +++ b/dlls/netapi32/netbios.c @@ -135,7 +135,7 @@ BOOL NetBIOSRegisterTransport(ULONG id, NetBIOSTransport *transport) TRACE(": transport 0x%08x, p %p\n", id, transport); if (!transport) ret = FALSE; - else if (gNumTransports >= sizeof(gTransports) / sizeof(gTransports[0])) + else if (gNumTransports >= ARRAY_SIZE(gTransports)) { FIXME("Too many transports %d\n", gNumTransports + 1); ret = FALSE;