[PATCH] user32: Use the ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Wed Aug 8 15:20:04 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/user32/driver.c    | 2 +-
 dlls/user32/icontitle.c | 4 ++--
 dlls/user32/lstr.c      | 4 ++--
 dlls/user32/user_main.c | 4 ++--
 dlls/user32/win.c       | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index d59a2eacf5..561a126bd6 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -57,7 +57,7 @@ static HMODULE load_desktop_driver( HWND hwnd )
     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( hwnd, display_device_guid_propW ));
 
     USER_CheckNotLock();
diff --git a/dlls/user32/icontitle.c b/dlls/user32/icontitle.c
index 95cb51331e..77e286ebc1 100644
--- a/dlls/user32/icontitle.c
+++ b/dlls/user32/icontitle.c
@@ -90,7 +90,7 @@ static BOOL ICONTITLE_SetTitlePos( HWND hwnd, HWND owner )
     INT cx, cy;
     POINT pt;
 
-    int length = GetWindowTextW( owner, str, sizeof(str)/sizeof(WCHAR) );
+    int length = GetWindowTextW( owner, str, ARRAY_SIZE( str ));
 
     while (length && str[length - 1] == ' ') /* remove trailing spaces */
         str[--length] = 0;
@@ -178,7 +178,7 @@ static BOOL ICONTITLE_Paint( HWND hwnd, HWND owner, HDC hDC, BOOL bActive )
     {
 	WCHAR buffer[80];
 
-        INT length = GetWindowTextW( owner, buffer, sizeof(buffer)/sizeof(buffer[0]) );
+        INT length = GetWindowTextW( owner, buffer, ARRAY_SIZE( buffer ));
         SetTextColor( hDC, textColor );
         SetBkMode( hDC, TRANSPARENT );
 
diff --git a/dlls/user32/lstr.c b/dlls/user32/lstr.c
index 80a2cfbe11..145a5c020d 100644
--- a/dlls/user32/lstr.c
+++ b/dlls/user32/lstr.c
@@ -335,7 +335,7 @@ DWORD WINAPI CharLowerBuffA( LPSTR str, DWORD len )
     if (!str) return 0; /* YES */
 
     lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
-    if (lenW > sizeof(buffer)/sizeof(WCHAR))
+    if (lenW > ARRAY_SIZE(buffer))
     {
         strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
         if (!strW) return 0;
@@ -370,7 +370,7 @@ DWORD WINAPI CharUpperBuffA( LPSTR str, DWORD len )
     if (!str) return 0; /* YES */
 
     lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
-    if (lenW > sizeof(buffer)/sizeof(WCHAR))
+    if (lenW > ARRAY_SIZE(buffer))
     {
         strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
         if (!strW) return 0;
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index e287150e21..007cb687f5 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -169,7 +169,7 @@ static const WCHAR *get_default_desktop(void)
     static const WCHAR app_defaultsW[] = {'S','o','f','t','w','a','r','e','\\',
                                           'W','i','n','e','\\',
                                           'A','p','p','D','e','f','a','u','l','t','s',0};
-    static WCHAR buffer[MAX_PATH + sizeof(explorerW)/sizeof(WCHAR)];
+    static WCHAR buffer[MAX_PATH + ARRAY_SIZE(explorerW)];
     WCHAR *p, *appname = buffer;
     const WCHAR *ret = defaultW;
     DWORD len;
@@ -433,7 +433,7 @@ BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reason )
     STARTUPINFOW si;
     void *redir;
 
-    GetSystemDirectoryW( app, MAX_PATH - sizeof(winebootW)/sizeof(WCHAR) );
+    GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE( winebootW ));
     strcatW( app, winebootW );
     strcpyW( cmdline, app );
 
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 5f2ac4e0d7..cbfd8bb14a 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -2049,8 +2049,8 @@ HWND WINAPI GetDesktopWindow(void)
         STARTUPINFOW si;
         PROCESS_INFORMATION pi;
         WCHAR windir[MAX_PATH];
-        WCHAR app[MAX_PATH + sizeof(explorer)/sizeof(WCHAR)];
-        WCHAR cmdline[MAX_PATH + (sizeof(explorer) + sizeof(args))/sizeof(WCHAR)];
+        WCHAR app[MAX_PATH + ARRAY_SIZE( explorer )];
+        WCHAR cmdline[MAX_PATH + ARRAY_SIZE( explorer ) + ARRAY_SIZE( args )];
         WCHAR desktop[MAX_PATH];
         void *redir;
 
-- 
2.14.4




More information about the wine-devel mailing list