[PATCH 2/2] winecfg: Use the available ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Thu May 17 17:17:06 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 programs/winecfg/appdefaults.c | 18 +++++++--------
 programs/winecfg/audio.c       | 37 ++++++++++++++----------------
 programs/winecfg/drive.c       |  2 +-
 programs/winecfg/drivedetect.c |  3 +--
 programs/winecfg/driveui.c     | 12 ++++------
 programs/winecfg/libraries.c   |  4 ++--
 programs/winecfg/theme.c       | 51 +++++++++++++++++-------------------------
 programs/winecfg/winecfg.c     | 10 ++++-----
 8 files changed, 58 insertions(+), 79 deletions(-)

diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c
index 61d515c707..e098c2b31a 100644
--- a/programs/winecfg/appdefaults.c
+++ b/programs/winecfg/appdefaults.c
@@ -174,8 +174,7 @@ init_comboboxes (HWND dialog)
     if (current_app)
     {
         WCHAR str[256];
-        LoadStringW (GetModuleHandleW(NULL), IDS_USE_GLOBAL_SETTINGS, str,
-            sizeof(str)/sizeof(str[0]));
+        LoadStringW(GetModuleHandleW(NULL), IDS_USE_GLOBAL_SETTINGS, str, ARRAY_SIZE(str));
         SendDlgItemMessageW (dialog, IDC_WINVER, CB_ADDSTRING, 0, (LPARAM)str);
     }
 
@@ -216,21 +215,20 @@ static void init_appsheet(HWND dialog)
 
   /* we use the lparam field of the item so we can alter the presentation later and not change code
    * for instance, to use the tile view or to display the EXEs embedded 'display name' */
-  LoadStringW (GetModuleHandleW(NULL), IDS_DEFAULT_SETTINGS, appname,
-      sizeof(appname)/sizeof(appname[0]));
+  LoadStringW(GetModuleHandleW(NULL), IDS_DEFAULT_SETTINGS, appname, ARRAY_SIZE(appname));
   add_listview_item(listview, appname, NULL);
 
   /* because this list is only populated once, it's safe to bypass the settings list here  */
   if (RegOpenKeyA(config_key, "AppDefaults", &key) == ERROR_SUCCESS)
   {
       i = 0;
-      size = sizeof(appname)/sizeof(appname[0]);
+      size = ARRAY_SIZE(appname);
       while (RegEnumKeyExW (key, i, appname, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
       {
           add_listview_item(listview, appname, strdupW(appname));
 
           i++;
-          size = sizeof(appname)/sizeof(appname[0]);
+          size = ARRAY_SIZE(appname);
       }
 
       RegCloseKey(key);
@@ -331,19 +329,19 @@ static void on_add_app_click(HWND dialog)
                        0, 0, NULL, 0, NULL };
 
   LoadStringW (GetModuleHandleW(NULL), IDS_SELECT_EXECUTABLE, selectExecutableStr,
-      sizeof(selectExecutableStr)/sizeof(selectExecutableStr[0]));
+      ARRAY_SIZE(selectExecutableStr));
   LoadStringW (GetModuleHandleW(NULL), IDS_EXECUTABLE_FILTER, programsFilter,
-      sizeof(programsFilter)/sizeof(programsFilter[0]));
+      ARRAY_SIZE(programsFilter));
   snprintfW( filter, MAX_PATH, filterW, programsFilter, 0, 0 );
 
   ofn.lpstrTitle = selectExecutableStr;
   ofn.lpstrFilter = filter;
   ofn.lpstrFileTitle = filetitle;
   ofn.lpstrFileTitle[0] = '\0';
-  ofn.nMaxFileTitle = sizeof(filetitle)/sizeof(filetitle[0]);
+  ofn.nMaxFileTitle = ARRAY_SIZE(filetitle);
   ofn.lpstrFile = file;
   ofn.lpstrFile[0] = '\0';
-  ofn.nMaxFile = sizeof(file)/sizeof(file[0]);
+  ofn.nMaxFile = ARRAY_SIZE(file);
 
   if (GetOpenFileNameW (&ofn))
   {
diff --git a/programs/winecfg/audio.c b/programs/winecfg/audio.c
index 4b22f3d50d..1e5f69de24 100644
--- a/programs/winecfg/audio.c
+++ b/programs/winecfg/audio.c
@@ -232,12 +232,11 @@ static void initAudioDlg (HWND hDlg)
 
     WINE_TRACE("\n");
 
-    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_DRIVER,
-            format_str, sizeof(format_str) / sizeof(*format_str));
-    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_DRIVER_NONE,
-            disabled_str, sizeof(disabled_str) / sizeof(*disabled_str));
-    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_SYSDEFAULT,
-            sysdefault_str, sizeof(sysdefault_str) / sizeof(*sysdefault_str));
+    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_DRIVER, format_str, ARRAY_SIZE(format_str));
+    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_DRIVER_NONE, disabled_str,
+            ARRAY_SIZE(disabled_str));
+    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_SYSDEFAULT, sysdefault_str,
+            ARRAY_SIZE(sysdefault_str));
 
     hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
             CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
@@ -250,8 +249,7 @@ static void initAudioDlg (HWND hDlg)
         PropVariantInit(&pv);
         if(get_driver_name(devenum, &pv) && pv.u.pwszVal[0] != '\0'){
             have_driver = TRUE;
-            wnsprintfW(display_str, sizeof(display_str) / sizeof(*display_str),
-                    format_str, pv.u.pwszVal);
+            wnsprintfW(display_str, ARRAY_SIZE(display_str), format_str, pv.u.pwszVal);
             lstrcatW(g_drv_keyW, pv.u.pwszVal);
         }
         PropVariantClear(&pv);
@@ -275,8 +273,8 @@ static void initAudioDlg (HWND hDlg)
 
     i = 0;
     while (speaker_configs[i].text_id != 0) {
-        LoadStringW(GetModuleHandleW(NULL), speaker_configs[i].text_id,
-            speaker_str, sizeof(speaker_str) / sizeof(*speaker_str));
+        LoadStringW(GetModuleHandleW(NULL), speaker_configs[i].text_id, speaker_str,
+                ARRAY_SIZE(speaker_str));
 
         SendDlgItemMessageW(hDlg, IDC_SPEAKERCONFIG_SPEAKERS, CB_ADDSTRING,
             0, (LPARAM)speaker_str);
@@ -287,14 +285,14 @@ static void initAudioDlg (HWND hDlg)
     GetClientRect(GetDlgItem(hDlg, IDC_LIST_AUDIO_DEVICES), &rect);
     width = (rect.right - rect.left) * 3 / 5;
 
-    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_DEVICE, colW, sizeof(colW)/sizeof(*colW));
+    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_DEVICE, colW, ARRAY_SIZE(colW));
     lvcol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
     lvcol.pszText = colW;
     lvcol.cchTextMax = lstrlenW(colW);
     lvcol.cx = width;
     SendDlgItemMessageW(hDlg, IDC_LIST_AUDIO_DEVICES, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvcol);
 
-    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_SPEAKER_CONFIG, colW, sizeof(colW)/sizeof(*colW));
+    LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_SPEAKER_CONFIG, colW, ARRAY_SIZE(colW));
     lvcol.pszText = colW;
     lvcol.cchTextMax = lstrlenW(colW);
     lvcol.cx = rect.right - rect.left - width;
@@ -343,7 +341,7 @@ static void initAudioDlg (HWND hDlg)
             SendDlgItemMessageW(hDlg, IDC_LIST_AUDIO_DEVICES, LVM_INSERTITEMW, 0, (LPARAM)&lvitem);
 
             LoadStringW(GetModuleHandleW(NULL), speaker_configs[render_devs[i].speaker_config].text_id,
-                speaker_str, sizeof(speaker_str) / sizeof(*speaker_str));
+                    speaker_str, ARRAY_SIZE(speaker_str));
 
             lvitem.mask = LVIF_TEXT;
             lvitem.iItem = i;
@@ -378,8 +376,7 @@ static void initAudioDlg (HWND hDlg)
         HeapFree(GetProcessHeap(), 0, reg_in_dev);
         HeapFree(GetProcessHeap(), 0, reg_vin_dev);
     }else
-        wnsprintfW(display_str, sizeof(display_str) / sizeof(*display_str),
-                format_str, disabled_str);
+        wnsprintfW(display_str, ARRAY_SIZE(display_str), format_str, disabled_str);
 
     SetDlgItemTextW(hDlg, IDC_AUDIO_DRIVER, display_str);
 }
@@ -405,10 +402,10 @@ static void test_sound(void)
     if(!PlaySoundW(MAKEINTRESOURCEW(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_ASYNC)){
         WCHAR error_str[256], title_str[256];
 
-        LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_TEST_FAILED,
-                error_str, sizeof(error_str) / sizeof(*error_str));
-        LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_TEST_FAILED_TITLE,
-                title_str, sizeof(title_str) / sizeof(*title_str));
+        LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_TEST_FAILED, error_str,
+                ARRAY_SIZE(error_str));
+        LoadStringW(GetModuleHandleW(NULL), IDS_AUDIO_TEST_FAILED_TITLE, title_str,
+                ARRAY_SIZE(title_str));
 
         MessageBoxW(NULL, error_str, title_str, MB_OK | MB_ICONERROR);
     }
@@ -527,7 +524,7 @@ AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
                       render_devs[dev].speaker_config = idx;
 
                       LoadStringW(GetModuleHandleW(NULL), speaker_configs[idx].text_id,
-                          speaker_str, sizeof(speaker_str) / sizeof(*speaker_str));
+                          speaker_str, ARRAY_SIZE(speaker_str));
 
                       lvitem.mask = LVIF_TEXT;
                       lvitem.iItem = dev;
diff --git a/programs/winecfg/drive.c b/programs/winecfg/drive.c
index b5ef69d423..ecd0d9aff4 100644
--- a/programs/winecfg/drive.c
+++ b/programs/winecfg/drive.c
@@ -284,7 +284,7 @@ BOOL load_drives(void)
             if (data->mount_point_offset) unixpath = (char *)data + data->mount_point_offset;
             if (data->device_offset) device = (char *)data + data->device_offset;
 
-            if (!GetVolumeInformationW( root, volname, sizeof(volname)/sizeof(WCHAR),
+            if (!GetVolumeInformationW( root, volname, ARRAY_SIZE(volname),
                                         &serial, NULL, NULL, NULL, 0 ))
             {
                 volname[0] = 0;
diff --git a/programs/winecfg/drivedetect.c b/programs/winecfg/drivedetect.c
index 253c6296a9..d56512354f 100644
--- a/programs/winecfg/drivedetect.c
+++ b/programs/winecfg/drivedetect.c
@@ -291,8 +291,7 @@ static void ensure_drive_c_is_mapped(void)
     if (stat(drive_c_dir, &buf) == 0)
     {
         WCHAR label[64];
-        LoadStringW (GetModuleHandleW(NULL), IDS_SYSTEM_DRIVE_LABEL, label,
-                     sizeof(label)/sizeof(label[0]));
+        LoadStringW(GetModuleHandleW(NULL), IDS_SYSTEM_DRIVE_LABEL, label, ARRAY_SIZE(label));
         add_drive('C', "../drive_c", NULL, label, 0, DRIVE_FIXED);
     }
     else
diff --git a/programs/winecfg/driveui.c b/programs/winecfg/driveui.c
index 98e057bd79..c25e71df52 100644
--- a/programs/winecfg/driveui.c
+++ b/programs/winecfg/driveui.c
@@ -340,8 +340,7 @@ static void on_add_click(HWND dialog)
     if (new == 'C')
     {
         WCHAR label[64];
-        LoadStringW (GetModuleHandleW(NULL), IDS_SYSTEM_DRIVE_LABEL, label,
-                     sizeof(label)/sizeof(label[0]));
+        LoadStringW(GetModuleHandleW(NULL), IDS_SYSTEM_DRIVE_LABEL, label, ARRAY_SIZE(label));
         add_drive(new, "../drive_c", NULL, label, 0, DRIVE_FIXED);
     }
     else add_drive(new, "/", NULL, NULL, 0, DRIVE_UNKNOWN);
@@ -444,8 +443,7 @@ static void update_controls(HWND dialog)
     for (i = 0; i < sizeof(type_pairs) / sizeof(struct drive_typemap); i++)
     {
         WCHAR driveDesc[64];
-        LoadStringW (GetModuleHandleW(NULL), type_pairs[i].idDesc, driveDesc,
-            sizeof(driveDesc)/sizeof(driveDesc[0]));
+        LoadStringW(GetModuleHandleW(NULL), type_pairs[i].idDesc, driveDesc, ARRAY_SIZE(driveDesc));
         SendDlgItemMessageW (dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)driveDesc);
 
         if (type_pairs[i].sCode ==  type)
@@ -633,8 +631,7 @@ static void init_listview_columns(HWND dialog)
     GetClientRect(GetDlgItem(dialog, IDC_LIST_DRIVES), &viewRect);
     width = (viewRect.right - viewRect.left) / 6 - 5;
 
-    LoadStringW (GetModuleHandleW(NULL), IDS_COL_DRIVELETTER, column,
-        sizeof(column)/sizeof(column[0]));
+    LoadStringW(GetModuleHandleW(NULL), IDS_COL_DRIVELETTER, column, ARRAY_SIZE(column));
     listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
     listColumn.pszText = column;
     listColumn.cchTextMax = lstrlenW (listColumn.pszText);
@@ -642,8 +639,7 @@ static void init_listview_columns(HWND dialog)
 
     SendDlgItemMessageW (dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMNW, 0, (LPARAM) &listColumn);
 
-    LoadStringW (GetModuleHandleW(NULL), IDS_COL_DRIVEMAPPING, column,
-        sizeof(column)/sizeof(column[0]));
+    LoadStringW(GetModuleHandleW(NULL), IDS_COL_DRIVEMAPPING, column, ARRAY_SIZE(column));
     listColumn.cx = viewRect.right - viewRect.left - width;
     listColumn.pszText = column;
     listColumn.cchTextMax = lstrlenW (listColumn.pszText);
diff --git a/programs/winecfg/libraries.c b/programs/winecfg/libraries.c
index d414c75a2f..22e9435e32 100644
--- a/programs/winecfg/libraries.c
+++ b/programs/winecfg/libraries.c
@@ -208,7 +208,7 @@ static inline BOOL is_builtin_only( const char *name )
             !strcmp( ext, ".tlb" ))
             return TRUE;
     }
-    return bsearch( &name, builtin_only, sizeof(builtin_only)/sizeof(builtin_only[0]),
+    return bsearch( &name, builtin_only, ARRAY_SIZE(builtin_only),
                     sizeof(builtin_only[0]), compare_dll ) != NULL;
 }
 
@@ -414,7 +414,7 @@ static void on_add_combo_change(HWND dialog)
     WCHAR buffer[1024];
     int sel, len;
 
-    SendDlgItemMessageW(dialog, IDC_DLLCOMBO, WM_GETTEXT, sizeof(buffer)/sizeof(WCHAR), (LPARAM) buffer);
+    SendDlgItemMessageW(dialog, IDC_DLLCOMBO, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
     /* if lib was chosen from combobox, we receive an empty buffer, check manually */
     sel=SendDlgItemMessageW(dialog, IDC_DLLCOMBO, CB_GETCURSEL, 0, 0);
     len=SendDlgItemMessageW(dialog, IDC_DLLCOMBO, CB_GETLBTEXTLEN, sel, 0);
diff --git a/programs/winecfg/theme.c b/programs/winecfg/theme.c
index 1d915bcaad..f98dcc3ae7 100644
--- a/programs/winecfg/theme.c
+++ b/programs/winecfg/theme.c
@@ -299,8 +299,7 @@ static BOOL fill_theme_list (HWND comboTheme, HWND comboColor, HWND comboSize)
     WCHAR currentSize[MAX_PATH];
     ThemeFile* theme = NULL;
 
-    LoadStringW (GetModuleHandleW(NULL), IDS_NOTHEME, textNoTheme,
-	sizeof(textNoTheme) / sizeof(WCHAR));
+    LoadStringW(GetModuleHandleW(NULL), IDS_NOTHEME, textNoTheme, ARRAY_SIZE(textNoTheme));
 
     SendMessageW (comboTheme, CB_RESETCONTENT, 0, 0);
     SendMessageW (comboTheme, CB_ADDSTRING, 0, (LPARAM)textNoTheme);
@@ -311,11 +310,9 @@ static BOOL fill_theme_list (HWND comboTheme, HWND comboColor, HWND comboSize)
 	SendMessageW (comboTheme, CB_ADDSTRING, 0, 
 	    (LPARAM)item->fancyName);
     }
-  
-    if (IsThemeActive () && SUCCEEDED (GetCurrentThemeName (currentTheme, 
-	    sizeof(currentTheme) / sizeof(WCHAR),
-	    currentColor, sizeof(currentColor) / sizeof(WCHAR),
-	    currentSize, sizeof(currentSize) / sizeof(WCHAR))))
+
+    if (IsThemeActive() && SUCCEEDED(GetCurrentThemeName(currentTheme, ARRAY_SIZE(currentTheme),
+                currentColor, ARRAY_SIZE(currentColor), currentSize, ARRAY_SIZE(currentSize))))
     {
 	/* Determine the index of the currently active theme. */
 	BOOL found = FALSE;
@@ -371,11 +368,9 @@ static BOOL update_color_and_size (int themeIndex, HWND comboColor,
 	ThemeFile* theme = DSA_GetItemPtr (themeFiles, themeIndex - 1);
     
 	fill_color_size_combos (theme, comboColor, comboSize);
-      
-	if ((SUCCEEDED (GetCurrentThemeName (currentTheme, 
-	    sizeof(currentTheme) / sizeof(WCHAR),
-	    currentColor, sizeof(currentColor) / sizeof(WCHAR),
-	    currentSize, sizeof(currentSize) / sizeof(WCHAR))))
+
+        if ((SUCCEEDED(GetCurrentThemeName (currentTheme, ARRAY_SIZE(currentTheme),
+            currentColor, ARRAY_SIZE(currentColor), currentSize, ARRAY_SIZE(currentSize))))
 	    && (lstrcmpiW (currentTheme, theme->themeFileName) == 0))
 	{
 	    select_color_and_size (theme, currentColor, comboColor,
@@ -560,7 +555,7 @@ static void set_color_from_theme(WCHAR *keyName, COLORREF color)
     keyNameA = HeapAlloc(GetProcessHeap(), 0, keyNameSize);
     WideCharToMultiByte(CP_ACP, 0, keyName, -1, keyNameA, keyNameSize, NULL, NULL);
 
-    for (i=0; i<sizeof(metrics)/sizeof(metrics[0]); i++)
+    for (i=0; i < ARRAY_SIZE(metrics); i++)
     {
         if (lstrcmpiA(metrics[i].color_reg, keyNameA)==0)
         {
@@ -620,19 +615,16 @@ static void on_theme_install(HWND dialog)
   static const WCHAR filterMask[] = {0,'*','.','m','s','s','t','y','l','e','s',';',
       '*','.','t','h','e','m','e',0,0};
   static const WCHAR themeExt[] = {'.','T','h','e','m','e',0};
-  const int filterMaskLen = sizeof(filterMask)/sizeof(filterMask[0]);
+  const int filterMaskLen = ARRAY_SIZE(filterMask);
   OPENFILENAMEW ofn;
   WCHAR filetitle[MAX_PATH];
   WCHAR file[MAX_PATH];
   WCHAR filter[100];
   WCHAR title[100];
 
-  LoadStringW (GetModuleHandleW(NULL), IDS_THEMEFILE,
-      filter, sizeof (filter) / sizeof (filter[0]) - filterMaskLen);
-  memcpy (filter + lstrlenW (filter), filterMask, 
-      filterMaskLen * sizeof (WCHAR));
-  LoadStringW (GetModuleHandleW(NULL), IDS_THEMEFILE_SELECT,
-      title, sizeof (title) / sizeof (title[0]));
+  LoadStringW(GetModuleHandleW(NULL), IDS_THEMEFILE, filter, ARRAY_SIZE(filter) - filterMaskLen);
+  memcpy(filter + lstrlenW (filter), filterMask, filterMaskLen * sizeof (WCHAR));
+  LoadStringW(GetModuleHandleW(NULL), IDS_THEMEFILE_SELECT, title, ARRAY_SIZE(title));
 
   ofn.lStructSize = sizeof(OPENFILENAMEW);
   ofn.hwndOwner = dialog;
@@ -646,7 +638,7 @@ static void on_theme_install(HWND dialog)
   ofn.nMaxFile = sizeof(file)/sizeof(filetitle[0]);
   ofn.lpstrFileTitle = filetitle;
   ofn.lpstrFileTitle[0] = '\0';
-  ofn.nMaxFileTitle = sizeof(filetitle)/sizeof(filetitle[0]);
+  ofn.nMaxFileTitle = ARRAY_SIZE(filetitle);
   ofn.lpstrInitialDir = NULL;
   ofn.lpstrTitle = title;
   ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
@@ -746,8 +738,8 @@ static void init_shell_folder_listview_headers(HWND dialog) {
     WCHAR szLinksTo[64] = {'L','i','n','k','s',' ','t','o',0};
     int width;
 
-    LoadStringW(GetModuleHandleW(NULL), IDS_SHELL_FOLDER, szShellFolder, sizeof(szShellFolder)/sizeof(WCHAR));
-    LoadStringW(GetModuleHandleW(NULL), IDS_LINKS_TO, szLinksTo, sizeof(szLinksTo)/sizeof(WCHAR));
+    LoadStringW(GetModuleHandleW(NULL), IDS_SHELL_FOLDER, szShellFolder, ARRAY_SIZE(szShellFolder));
+    LoadStringW(GetModuleHandleW(NULL), IDS_LINKS_TO, szLinksTo, ARRAY_SIZE(szLinksTo));
 
     GetClientRect(GetDlgItem(dialog, IDC_LIST_SFPATHS), &viewRect);
     width = (viewRect.right - viewRect.left) / 3;
@@ -965,7 +957,7 @@ static void refresh_sysparams(HWND hDlg)
 {
     int i;
 
-    for (i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(metrics); i++)
     {
         if (metrics[i].sm_idx != -1)
             metrics[i].size = GetSystemMetrics(metrics[i].sm_idx);
@@ -983,10 +975,9 @@ static void read_sysparams(HWND hDlg)
     NONCLIENTMETRICSW nonclient_metrics;
     int i, idx;
 
-    for (i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(metrics); i++)
     {
-        LoadStringW(GetModuleHandleW(NULL), i + IDC_SYSPARAMS_BUTTON, buffer,
-                    sizeof(buffer) / sizeof(buffer[0]));
+        LoadStringW(GetModuleHandleW(NULL), i + IDC_SYSPARAMS_BUTTON, buffer, ARRAY_SIZE(buffer));
         idx = SendMessageW(list, CB_ADDSTRING, 0, (LPARAM)buffer);
         if (idx != CB_ERR) SendMessageW(list, CB_SETITEMDATA, idx, i);
 
@@ -1013,8 +1004,8 @@ static void apply_sysparams(void)
 {
     NONCLIENTMETRICSW ncm;
     int i, cnt = 0;
-    int colors_idx[sizeof(metrics) / sizeof(metrics[0])];
-    COLORREF colors[sizeof(metrics) / sizeof(metrics[0])];
+    int colors_idx[ARRAY_SIZE(metrics)];
+    COLORREF colors[ARRAY_SIZE(metrics)];
     HDC hdc;
     int dpi;
 
@@ -1049,7 +1040,7 @@ static void apply_sysparams(void)
     SystemParametersInfoW(SPI_SETNONCLIENTMETRICS, sizeof(ncm), &ncm,
                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
 
-    for (i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(metrics); i++)
         if (metrics[i].color_idx != -1)
         {
             colors_idx[cnt] = metrics[i].color_idx;
diff --git a/programs/winecfg/winecfg.c b/programs/winecfg/winecfg.c
index ba317c7755..be04ba2a77 100644
--- a/programs/winecfg/winecfg.c
+++ b/programs/winecfg/winecfg.c
@@ -62,14 +62,12 @@ void set_window_title(HWND dialog)
     if (current_app)
     {
         WCHAR apptitle[256];
-        LoadStringW (GetModuleHandleW(NULL), IDS_WINECFG_TITLE_APP, apptitle,
-            sizeof(apptitle)/sizeof(apptitle[0]));
+        LoadStringW(GetModuleHandleW(NULL), IDS_WINECFG_TITLE_APP, apptitle, ARRAY_SIZE(apptitle));
         wsprintfW (newtitle, apptitle, current_app);
     }
     else
     {
-        LoadStringW (GetModuleHandleW(NULL), IDS_WINECFG_TITLE, newtitle,
-            sizeof(newtitle)/sizeof(newtitle[0]));
+        LoadStringW(GetModuleHandleW(NULL), IDS_WINECFG_TITLE, newtitle, ARRAY_SIZE(newtitle));
     }
 
     WINE_TRACE("setting title to %s\n", wine_dbgstr_w (newtitle));
@@ -83,7 +81,7 @@ WCHAR* load_string (UINT id)
     int len;
     WCHAR* newStr;
 
-    LoadStringW (GetModuleHandleW(NULL), id, buf, sizeof(buf)/sizeof(buf[0]));
+    LoadStringW(GetModuleHandleW(NULL), id, buf, ARRAY_SIZE(buf));
 
     len = lstrlenW (buf);
     newStr = HeapAlloc (GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR));
@@ -477,7 +475,7 @@ static WCHAR **enumerate_valuesW(HKEY root, WCHAR *path)
         while (TRUE)
         {
             WCHAR name[1024];
-            DWORD namesize = sizeof(name)/sizeof(name[0]);
+            DWORD namesize = ARRAY_SIZE(name);
             BOOL removed = FALSE;
 
             /* find out the needed size, allocate a buffer, read the value  */
-- 
2.14.3




More information about the wine-devel mailing list