From 7fdb828abf6324c80fba7e0b62498912fe4b5f17 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Fri, 18 May 2018 00:17:06 +0200 Subject: [PATCH] winecfg: Use the available ARRAY_SIZE() macro. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- 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 61d515c7077..e098c2b31ab 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 4b22f3d50df..1e5f69de24b 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 b5ef69d4230..ecd0d9aff44 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 253c6296a9b..d56512354fb 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 98e057bd795..c25e71df523 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 d414c75a2f8..22e9435e328 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 1d915bcaade..f98dcc3ae75 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