[PATCH] mscoree: Use the ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Wed Jul 25 17:05:57 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/mscoree/config.c         | 18 +++++++-----------
 dlls/mscoree/corruntimehost.c |  6 +++---
 dlls/mscoree/mscoree_main.c   |  4 ++--
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/dlls/mscoree/config.c b/dlls/mscoree/config.c
index 48f12f4d53..a5c0666904 100644
--- a/dlls/mscoree/config.c
+++ b/dlls/mscoree/config.c
@@ -417,7 +417,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface,
     TRACE("%s %s %s\n", debugstr_wn(pNamespaceUri,nNamespaceUri),
         debugstr_wn(pLocalName,nLocalName), debugstr_wn(pQName,nQName));
 
-    if (This->statenum == sizeof(This->states) / sizeof(This->states[0]) - 1)
+    if (This->statenum == ARRAY_SIZE(This->states) - 1)
     {
         ERR("file has too much nesting\n");
         return E_FAIL;
@@ -426,8 +426,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface,
     switch (This->states[This->statenum])
     {
     case STATE_ROOT:
-        if (nLocalName == sizeof(configuration)/sizeof(WCHAR)-1 &&
-            lstrcmpW(pLocalName, configuration) == 0)
+        if (nLocalName == ARRAY_SIZE(configuration) - 1 && lstrcmpW(pLocalName, configuration) == 0)
         {
             This->states[++This->statenum] = STATE_CONFIGURATION;
             break;
@@ -435,15 +434,13 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface,
         else
             goto unknown;
     case STATE_CONFIGURATION:
-        if (nLocalName == sizeof(startup)/sizeof(WCHAR)-1 &&
-            lstrcmpW(pLocalName, startup) == 0)
+        if (nLocalName == ARRAY_SIZE(startup) - 1 && lstrcmpW(pLocalName, startup) == 0)
         {
             hr = parse_startup(This, pAttr);
             This->states[++This->statenum] = STATE_STARTUP;
             break;
         }
-        else if (nLocalName == sizeof(runtime)/sizeof(WCHAR)-1 &&
-            lstrcmpW(pLocalName, runtime) == 0)
+        else if (nLocalName == ARRAY_SIZE(runtime) - 1 && lstrcmpW(pLocalName, runtime) == 0)
         {
             This->states[++This->statenum] = STATE_RUNTIME;
             break;
@@ -451,7 +448,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface,
         else
             goto unknown;
     case STATE_RUNTIME:
-        if (nLocalName == sizeof(assemblyBinding)/sizeof(WCHAR)-1 &&
+        if (nLocalName == ARRAY_SIZE(assemblyBinding) - 1 &&
             lstrcmpW(pLocalName, assemblyBinding) == 0)
         {
             This->states[++This->statenum] = STATE_ASSEMBLY_BINDING;
@@ -460,8 +457,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface,
         else
             goto unknown;
     case STATE_ASSEMBLY_BINDING:
-        if (nLocalName == sizeof(probing)/sizeof(WCHAR)-1 &&
-            lstrcmpW(pLocalName, probing) == 0)
+        if (nLocalName == ARRAY_SIZE(probing) - 1 && lstrcmpW(pLocalName, probing) == 0)
         {
             hr = parse_probing(This, pAttr);
             This->states[++This->statenum] = STATE_PROBING;
@@ -470,7 +466,7 @@ static HRESULT WINAPI ConfigFileHandler_startElement(ISAXContentHandler *iface,
         else
             goto unknown;
     case STATE_STARTUP:
-        if (nLocalName == sizeof(supportedRuntime)/sizeof(WCHAR)-1 &&
+        if (nLocalName == ARRAY_SIZE(supportedRuntime) - 1 &&
             lstrcmpW(pLocalName, supportedRuntime) == 0)
         {
             hr = parse_supported_runtime(This, pAttr);
diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 0c933cac29..5c4e7f1d6e 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -138,7 +138,7 @@ static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, const WCHAR *conf
 
     if (!config_path)
     {
-        DWORD len = sizeof(config_dir)/sizeof(*config_dir);
+        DWORD len = ARRAY_SIZE(config_dir);
 
         static const WCHAR machine_configW[] = {'\\','C','O','N','F','I','G','\\','m','a','c','h','i','n','e','.','c','o','n','f','i','g',0};
 
@@ -159,7 +159,7 @@ static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, const WCHAR *conf
         goto end;
     }
 
-    GetModuleFileNameW(NULL, base_dir, sizeof(base_dir) / sizeof(*base_dir));
+    GetModuleFileNameW(NULL, base_dir, ARRAY_SIZE(base_dir));
     base_dirA = WtoA(base_dir);
     if (!base_dirA)
     {
@@ -1674,7 +1674,7 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj )
         if (res != ERROR_SUCCESS || numKeys == 0)
             goto cleanup;
         numKeys--;
-        keyLength = sizeof(subkeyName) / sizeof(WCHAR);
+        keyLength = ARRAY_SIZE(subkeyName);
         res = RegEnumKeyExW(key, numKeys, subkeyName, &keyLength, 0, 0, 0, 0);
         if (res != ERROR_SUCCESS)
             goto cleanup;
diff --git a/dlls/mscoree/mscoree_main.c b/dlls/mscoree/mscoree_main.c
index eda380a1ca..5612ff6b89 100644
--- a/dlls/mscoree/mscoree_main.c
+++ b/dlls/mscoree/mscoree_main.c
@@ -751,7 +751,7 @@ static BOOL install_wine_mono(void)
         }
     }
 
-    len = GetSystemDirectoryW(app, MAX_PATH-sizeof(controlW)/sizeof(WCHAR));
+    len = GetSystemDirectoryW(app, MAX_PATH - ARRAY_SIZE(controlW));
     memcpy(app+len, controlW, sizeof(controlW));
 
     args = HeapAlloc(GetProcessHeap(), 0, (len*sizeof(WCHAR) + sizeof(controlW) + sizeof(argsW)));
@@ -759,7 +759,7 @@ static BOOL install_wine_mono(void)
         return FALSE;
 
     memcpy(args, app, len*sizeof(WCHAR) + sizeof(controlW));
-    memcpy(args + len + sizeof(controlW)/sizeof(WCHAR)-1, argsW, sizeof(argsW));
+    memcpy(args + len + ARRAY_SIZE(controlW) - 1, argsW, sizeof(argsW));
 
     TRACE("starting %s\n", debugstr_w(args));
 
-- 
2.14.4




More information about the wine-devel mailing list