[PATCH] imm32: Use the ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Sat Aug 4 15:45:42 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/imm32/imm.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 685eb018c4..f235e228ad 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -308,7 +308,7 @@ static HMODULE load_graphics_driver(void)
     HKEY hkey;
     DWORD size;
     WCHAR path[MAX_PATH];
-    WCHAR key[(sizeof(key_pathW) + sizeof(displayW)) / sizeof(WCHAR) + 40];
+    WCHAR key[ARRAY_SIZE( key_pathW ) + ARRAY_SIZE( displayW ) + 40];
     UINT guid_atom = HandleToULong( GetPropW( GetDesktopWindow(), display_device_guid_propW ));
 
     if (!guid_atom) return 0;
@@ -769,7 +769,7 @@ HIMC WINAPI ImmCreateContext(void)
     gl->dwSize = sizeof(GUIDELINE);
     ImmUnlockIMCC(new_context->IMC.hGuideLine);
 
-    for (i = 0; i < sizeof(new_context->IMC.cfCandForm) / sizeof(CANDIDATEFORM); i++)
+    for (i = 0; i < ARRAY_SIZE(new_context->IMC.cfCandForm); i++)
         new_context->IMC.cfCandForm[i].dwIndex = ~0u;
 
     /* Initialize the IME Private */
@@ -1013,8 +1013,7 @@ DWORD WINAPI ImmGetCandidateListA(
        return 0;
 
     candinfo = ImmLockIMCC(data->IMC.hCandInfo);
-    if ( dwIndex >= candinfo->dwCount ||
-         dwIndex >= (sizeof(candinfo->dwOffset) / sizeof(DWORD)) )
+    if (dwIndex >= candinfo->dwCount || dwIndex >= ARRAY_SIZE(candinfo->dwOffset))
         goto done;
 
     candlist = (LPCANDIDATELIST)((LPBYTE)candinfo + candinfo->dwOffset[dwIndex]);
@@ -1117,8 +1116,7 @@ DWORD WINAPI ImmGetCandidateListW(
        return 0;
 
     candinfo = ImmLockIMCC(data->IMC.hCandInfo);
-    if ( dwIndex >= candinfo->dwCount ||
-         dwIndex >= (sizeof(candinfo->dwOffset) / sizeof(DWORD)) )
+    if (dwIndex >= candinfo->dwCount || dwIndex >= ARRAY_SIZE(candinfo->dwOffset))
         goto done;
 
     candlist = (LPCANDIDATELIST)((LPBYTE)candinfo + candinfo->dwOffset[dwIndex]);
@@ -1152,7 +1150,7 @@ BOOL WINAPI ImmGetCandidateWindow(
     if (!data || !lpCandidate)
         return FALSE;
 
-    if ( dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) )
+    if (dwIndex >= ARRAY_SIZE(data->IMC.cfCandForm))
         return FALSE;
 
     if (data->IMC.cfCandForm[dwIndex].dwIndex != dwIndex)
@@ -1624,8 +1622,7 @@ static BOOL needs_ime_window(HWND hwnd)
 {
     WCHAR classW[8];
 
-    if (GetClassNameW(hwnd, classW, sizeof(classW)/sizeof(classW[0])) &&
-        !strcmpW(classW, szwIME))
+    if (GetClassNameW(hwnd, classW, ARRAY_SIZE(classW)) && !strcmpW(classW, szwIME))
         return FALSE;
     if (GetClassLongPtrW(hwnd, GCL_STYLE) & CS_IME) return FALSE;
 
@@ -1844,7 +1841,7 @@ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen)
     HKEY hkey;
     DWORD length;
     DWORD rc;
-    WCHAR regKey[sizeof(szImeRegFmt)/sizeof(WCHAR)+8];
+    WCHAR regKey[ARRAY_SIZE(szImeRegFmt)+8];
 
     wsprintfW( regKey, szImeRegFmt, (ULONG_PTR)hKL );
     rc = RegOpenKeyW( HKEY_LOCAL_MACHINE, regKey, &hkey);
@@ -2062,7 +2059,7 @@ HKL WINAPI ImmInstallIMEW(
     HKL hkl;
     DWORD rc;
     HKEY hkey;
-    WCHAR regKey[sizeof(szImeRegFmt)/sizeof(WCHAR)+8];
+    WCHAR regKey[ARRAY_SIZE(szImeRegFmt)+8];
 
     TRACE ("(%s, %s):\n", debugstr_w(lpszIMEFileName),
                           debugstr_w(lpszLayoutText));
@@ -2314,7 +2311,7 @@ BOOL WINAPI ImmSetCandidateWindow(
           wine_dbgstr_point(&lpCandidate->ptCurrentPos),
           wine_dbgstr_rect(&lpCandidate->rcArea));
 
-    if ( lpCandidate->dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) )
+    if (lpCandidate->dwIndex >= ARRAY_SIZE(data->IMC.cfCandForm))
         return FALSE;
 
     data->IMC.cfCandForm[lpCandidate->dwIndex] = *lpCandidate;
-- 
2.14.4




More information about the wine-devel mailing list