Commit 84b7a8f0 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

localspl: Use the ARRAY_SIZE() macro.

parent a486cd78
...@@ -279,10 +279,10 @@ static DWORD get_type_from_name(LPCWSTR name) ...@@ -279,10 +279,10 @@ static DWORD get_type_from_name(LPCWSTR name)
{ {
HANDLE hfile; HANDLE hfile;
if (!strncmpW(name, portname_LPT, sizeof(portname_LPT) / sizeof(WCHAR) -1)) if (!strncmpW(name, portname_LPT, ARRAY_SIZE(portname_LPT) - 1))
return PORT_IS_LPT; return PORT_IS_LPT;
if (!strncmpW(name, portname_COM, sizeof(portname_COM) / sizeof(WCHAR) -1)) if (!strncmpW(name, portname_COM, ARRAY_SIZE(portname_COM) - 1))
return PORT_IS_COM; return PORT_IS_COM;
if (!strcmpW(name, portname_FILE)) if (!strcmpW(name, portname_FILE))
...@@ -294,10 +294,10 @@ static DWORD get_type_from_name(LPCWSTR name) ...@@ -294,10 +294,10 @@ static DWORD get_type_from_name(LPCWSTR name)
if (name[0] == '|') if (name[0] == '|')
return PORT_IS_PIPE; return PORT_IS_PIPE;
if (!strncmpW(name, portname_CUPS, sizeof(portname_CUPS) / sizeof(WCHAR) -1)) if (!strncmpW(name, portname_CUPS, ARRAY_SIZE(portname_CUPS) - 1))
return PORT_IS_CUPS; return PORT_IS_CUPS;
if (!strncmpW(name, portname_LPR, sizeof(portname_LPR) / sizeof(WCHAR) -1)) if (!strncmpW(name, portname_LPR, ARRAY_SIZE(portname_LPR) - 1))
return PORT_IS_LPR; return PORT_IS_LPR;
/* Must be a file or a directory. Does the file exist ? */ /* Must be a file or a directory. Does the file exist ? */
...@@ -704,7 +704,7 @@ static DWORD WINAPI localmon_XcvDataPort(HANDLE hXcv, LPCWSTR pszDataName, PBYTE ...@@ -704,7 +704,7 @@ static DWORD WINAPI localmon_XcvDataPort(HANDLE hXcv, LPCWSTR pszDataName, PBYTE
{ {
ptr = ((xcv_t *)hXcv)->nameW; ptr = ((xcv_t *)hXcv)->nameW;
} }
lstrcpynW(buffer, ptr, sizeof(buffer)/sizeof(WCHAR)); lstrcpynW(buffer, ptr, ARRAY_SIZE(buffer));
if (buffer[0]) buffer[lstrlenW(buffer)-1] = '\0'; /* remove the ':' */ if (buffer[0]) buffer[lstrlenW(buffer)-1] = '\0'; /* remove the ':' */
res = SetDefaultCommConfigW(buffer, (LPCOMMCONFIG) pInputData, cbInputData); res = SetDefaultCommConfigW(buffer, (LPCOMMCONFIG) pInputData, cbInputData);
TRACE("got %u with %u\n", res, GetLastError() ); TRACE("got %u with %u\n", res, GetLastError() );
......
...@@ -275,7 +275,7 @@ static LONG copy_servername_from_name(LPCWSTR name, LPWSTR target) ...@@ -275,7 +275,7 @@ static LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
target[serverlen] = '\0'; target[serverlen] = '\0';
} }
len = sizeof(buffer) / sizeof(buffer[0]); len = ARRAY_SIZE(buffer);
if (GetComputerNameW(buffer, &len)) { if (GetComputerNameW(buffer, &len)) {
if ((serverlen == len) && (strncmpiW(server, buffer, len) == 0)) { if ((serverlen == len) && (strncmpiW(server, buffer, len) == 0)) {
/* The requested Servername is our computername */ /* The requested Servername is our computername */
...@@ -693,7 +693,7 @@ static const printenv_t * validate_envW(LPCWSTR env) ...@@ -693,7 +693,7 @@ static const printenv_t * validate_envW(LPCWSTR env)
TRACE("(%s)\n", debugstr_w(env)); TRACE("(%s)\n", debugstr_w(env));
if (env && env[0]) if (env && env[0])
{ {
for (i = 0; i < sizeof(all_printenv)/sizeof(all_printenv[0]); i++) for (i = 0; i < ARRAY_SIZE(all_printenv); i++)
{ {
if (lstrcmpiW(env, all_printenv[i]->envname) == 0) if (lstrcmpiW(env, all_printenv[i]->envname) == 0)
{ {
...@@ -749,7 +749,7 @@ static DWORD get_local_monitors(DWORD level, LPBYTE pMonitors, DWORD cbBuf, LPDW ...@@ -749,7 +749,7 @@ static DWORD get_local_monitors(DWORD level, LPBYTE pMonitors, DWORD cbBuf, LPDW
ptr = (LPWSTR) &pMonitors[len]; ptr = (LPWSTR) &pMonitors[len];
numentries = 0; numentries = 0;
len = sizeof(buffer)/sizeof(buffer[0]); len = ARRAY_SIZE(buffer);
buffer[0] = '\0'; buffer[0] = '\0';
/* Windows creates the "Monitors"-Key on reboot / start "spooler" */ /* Windows creates the "Monitors"-Key on reboot / start "spooler" */
...@@ -802,7 +802,7 @@ static DWORD get_local_monitors(DWORD level, LPBYTE pMonitors, DWORD cbBuf, LPDW ...@@ -802,7 +802,7 @@ static DWORD get_local_monitors(DWORD level, LPBYTE pMonitors, DWORD cbBuf, LPDW
} }
} }
index++; index++;
len = sizeof(buffer)/sizeof(buffer[0]); len = ARRAY_SIZE(buffer);
buffer[0] = '\0'; buffer[0] = '\0';
} }
RegCloseKey(hroot); RegCloseKey(hroot);
...@@ -838,7 +838,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb ...@@ -838,7 +838,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb
ptr = (LPWSTR) &pPPInfo[len]; ptr = (LPWSTR) &pPPInfo[len];
numentries = 0; numentries = 0;
len = sizeof(buffer)/sizeof(buffer[0]); len = ARRAY_SIZE(buffer);
buffer[0] = '\0'; buffer[0] = '\0';
if (RegCreateKeyW(HKEY_LOCAL_MACHINE, regpathW, &hroot) == ERROR_SUCCESS) { if (RegCreateKeyW(HKEY_LOCAL_MACHINE, regpathW, &hroot) == ERROR_SUCCESS) {
...@@ -852,7 +852,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb ...@@ -852,7 +852,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb
TRACE("%p: writing PRINTPROCESSOR_INFO_1W #%d\n", ppi, numentries); TRACE("%p: writing PRINTPROCESSOR_INFO_1W #%d\n", ppi, numentries);
ppi->pName = ptr; ppi->pName = ptr;
lstrcpyW(ptr, winprintW); /* Name of the Print Processor */ lstrcpyW(ptr, winprintW); /* Name of the Print Processor */
ptr += sizeof(winprintW) / sizeof(WCHAR); ptr += ARRAY_SIZE(winprintW);
} }
/* Scan all Printprocessor Keys */ /* Scan all Printprocessor Keys */
...@@ -888,7 +888,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb ...@@ -888,7 +888,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb
} }
} }
index++; index++;
len = sizeof(buffer)/sizeof(buffer[0]); len = ARRAY_SIZE(buffer);
buffer[0] = '\0'; buffer[0] = '\0';
} }
RegCloseKey(hroot); RegCloseKey(hroot);
...@@ -1196,7 +1196,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault) ...@@ -1196,7 +1196,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault)
printer = NULL; printer = NULL;
} }
if (printername) { if (printername) {
len = sizeof(XcvMonitorW)/sizeof(WCHAR) - 1; len = ARRAY_SIZE(XcvMonitorW) - 1;
if (strncmpW(printername, XcvMonitorW, len) == 0) { if (strncmpW(printername, XcvMonitorW, len) == 0) {
/* OpenPrinter(",XcvMonitor ", ...) detected */ /* OpenPrinter(",XcvMonitor ", ...) detected */
TRACE(",XcvMonitor: %s\n", debugstr_w(&printername[len])); TRACE(",XcvMonitor: %s\n", debugstr_w(&printername[len]));
...@@ -1210,7 +1210,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault) ...@@ -1210,7 +1210,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault)
} }
else else
{ {
len = sizeof(XcvPortW)/sizeof(WCHAR) - 1; len = ARRAY_SIZE(XcvPortW) - 1;
if (strncmpW( printername, XcvPortW, len) == 0) { if (strncmpW( printername, XcvPortW, len) == 0) {
/* OpenPrinter(",XcvPort ", ...) detected */ /* OpenPrinter(",XcvPort ", ...) detected */
TRACE(",XcvPort: %s\n", debugstr_w(&printername[len])); TRACE(",XcvPort: %s\n", debugstr_w(&printername[len]));
...@@ -1303,7 +1303,7 @@ static BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCo ...@@ -1303,7 +1303,7 @@ static BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCo
DRIVER_INFO, that the caller supplied */ DRIVER_INFO, that the caller supplied */
ZeroMemory(&di, sizeof(di)); ZeroMemory(&di, sizeof(di));
if (pDriverInfo && (level < (sizeof(di_sizeof) / sizeof(di_sizeof[0])))) { if (pDriverInfo && (level < ARRAY_SIZE(di_sizeof))) {
memcpy(&di, pDriverInfo, di_sizeof[level]); memcpy(&di, pDriverInfo, di_sizeof[level]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment