Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- Not compile tested so if somebody with a Mac could check it that would be much appreciated.
dlls/winemac.drv/clipboard.c | 12 ++++---- dlls/winemac.drv/display.c | 8 ++--- dlls/winemac.drv/gdi.c | 3 +- dlls/winemac.drv/keyboard.c | 70 ++++++++++++++++++++---------------------- dlls/winemac.drv/macdrv_main.c | 4 +-- dlls/winemac.drv/mouse.c | 10 +++--- dlls/winemac.drv/opengl.c | 30 +++++++++--------- dlls/winemac.drv/systray.c | 2 +- dlls/winemac.drv/window.c | 2 +- 9 files changed, 69 insertions(+), 72 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index ac0dc3101a..cf5d56b1f1 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -280,7 +280,7 @@ static WINE_CLIPFORMAT *insert_clipboard_format(UINT id, CFStringRef type) { WCHAR buffer[256];
- if (!GetClipboardFormatNameW(format->format_id, buffer, sizeof(buffer) / sizeof(buffer[0]))) + if (!GetClipboardFormatNameW(format->format_id, buffer, ARRAY_SIZE(buffer))) { WARN("failed to get name for format %s; error 0x%08x\n", debugstr_format(format->format_id), GetLastError()); HeapFree(GetProcessHeap(), 0, format); @@ -347,7 +347,7 @@ static void register_builtin_formats(void) WINE_CLIPFORMAT *format;
/* Register built-in formats */ - for (i = 0; i < sizeof(builtin_format_ids)/sizeof(builtin_format_ids[0]); i++) + for (i = 0; i < ARRAY_SIZE(builtin_format_ids); i++) { if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break; format->format_id = builtin_format_ids[i].id; @@ -360,7 +360,7 @@ static void register_builtin_formats(void) }
/* Register known mappings between Windows formats and Mac types */ - for (i = 0; i < sizeof(builtin_format_names)/sizeof(builtin_format_names[0]); i++) + for (i = 0; i < ARRAY_SIZE(builtin_format_names); i++) { if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break; format->format_id = RegisterClipboardFormatW(builtin_format_names[i].name); @@ -1841,12 +1841,12 @@ static LRESULT CALLBACK clipboard_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM static BOOL wait_clipboard_mutex(void) { static const WCHAR prefix[] = {'_','_','w','i','n','e','_','c','l','i','p','b','o','a','r','d','_'}; - WCHAR buffer[MAX_PATH + sizeof(prefix) / sizeof(WCHAR)]; + WCHAR buffer[MAX_PATH + ARRAY_SIZE(prefix)]; HANDLE mutex;
memcpy(buffer, prefix, sizeof(prefix)); if (!GetUserObjectInformationW(GetProcessWindowStation(), UOI_NAME, - buffer + sizeof(prefix) / sizeof(WCHAR), + buffer + ARRAY_SIZE(prefix), sizeof(buffer) - sizeof(prefix), NULL)) { ERR("failed to get winstation name\n"); @@ -1873,7 +1873,7 @@ static BOOL CALLBACK init_pipe_name(INIT_ONCE* once, void* param, void** context
memcpy(clipboard_pipe_name, prefix, sizeof(prefix)); if (!GetUserObjectInformationW(GetProcessWindowStation(), UOI_NAME, - clipboard_pipe_name + sizeof(prefix) / sizeof(WCHAR), + clipboard_pipe_name + ARRAY_SIZE(prefix), sizeof(clipboard_pipe_name) - sizeof(prefix), NULL)) { ERR("failed to get winstation name\n"); diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 49892ca3ef..00ad7738bb 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -519,7 +519,7 @@ static CFDictionaryRef create_mode_dict(CGDisplayModeRef display_mode, BOOL is_o CFSTR("pixel_encoding"), CFSTR("refresh_rate"), }; - const void* values[sizeof(keys) / sizeof(keys[0])] = { + const void* values[ARRAY_SIZE(keys)] = { cf_io_flags, cf_width, cf_height, @@ -527,7 +527,7 @@ static CFDictionaryRef create_mode_dict(CGDisplayModeRef display_mode, BOOL is_o cf_refresh, };
- ret = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, sizeof(keys) / sizeof(keys[0]), + ret = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, ARRAY_SIZE(keys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); }
@@ -1182,7 +1182,7 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) struct macdrv_display *displays; int num_displays; uint32_t mac_entries; - int win_entries = sizeof(r->red) / sizeof(r->red[0]); + int win_entries = ARRAY_SIZE(r->red); CGGammaValue *red, *green, *blue; CGError err; int win_entry; @@ -1316,7 +1316,7 @@ BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) DDGAMMARAMP *r = ramp; struct macdrv_display *displays; int num_displays; - int win_entries = sizeof(r->red) / sizeof(r->red[0]); + int win_entries = ARRAY_SIZE(r->red); CGGammaValue *red, *green, *blue; int i; CGError err = kCGErrorFailure; diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index 77da2334ee..79dc3488cc 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -72,8 +72,7 @@ static void compute_desktop_rect(void) uint32_t count, i;
desktop_rect = CGRectNull; - if (CGGetActiveDisplayList(sizeof(displayIDs)/sizeof(displayIDs[0]), - displayIDs, &count) != kCGErrorSuccess || + if (CGGetActiveDisplayList(ARRAY_SIZE(displayIDs), displayIDs, &count) != kCGErrorSuccess || !count) { displayIDs[0] = CGMainDisplayID(); diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 3e0ebbf6ec..aa47b95ed0 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -456,7 +456,7 @@ static DWORD get_lcid(CFStringRef lang) WCHAR str[10];
range.location = 0; - range.length = min(CFStringGetLength(lang), sizeof(str) / sizeof(str[0]) - 1); + range.length = min(CFStringGetLength(lang), ARRAY_SIZE(str) - 1); CFStringGetCharacters(lang, range, str); str[range.length] = 0; return LocaleNameToLCID(str, 0); @@ -593,7 +593,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) optionKey >> 8, (shiftKey | optionKey) >> 8, }; - UniChar map[128][sizeof(modifier_combos) / sizeof(modifier_combos[0])][4 + 1]; + UniChar map[128][ARRAY_SIZE(modifier_combos)][4 + 1]; int combo; BYTE vkey_used[256]; int ignore_diacritics; @@ -673,7 +673,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) memset(thread_data->keyc2vkey, 0, sizeof(thread_data->keyc2vkey)); memset(vkey_used, 0, sizeof(vkey_used));
- for (keyc = 0; keyc < sizeof(default_map) / sizeof(default_map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(default_map); keyc++) { thread_data->keyc2scan[keyc] = default_map[keyc].scan; if (default_map[keyc].fixed) @@ -708,14 +708,14 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data)
/* Using the keyboard layout, build a map of key code + modifiers -> characters. */ memset(map, 0, sizeof(map)); - for (keyc = 0; keyc < sizeof(map) / sizeof(map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(map); keyc++) { if (!thread_data->keyc2scan[keyc]) continue; /* not a known Mac key code */ if (thread_data->keyc2vkey[keyc]) continue; /* assigned a fixed vkey */
TRACE("keyc 0x%04x: ", keyc);
- for (combo = 0; combo < sizeof(modifier_combos) / sizeof(modifier_combos[0]); combo++) + for (combo = 0; combo < ARRAY_SIZE(modifier_combos); combo++) { UInt32 deadKeyState; UniCharCount len; @@ -724,8 +724,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) deadKeyState = 0; status = UCKeyTranslate(uchr, keyc, kUCKeyActionDown, modifier_combos[combo], thread_data->keyboard_type, kUCKeyTranslateNoDeadKeysMask, - &deadKeyState, sizeof(map[keyc][combo])/sizeof(map[keyc][combo][0]) - 1, - &len, map[keyc][combo]); + &deadKeyState, ARRAY_SIZE(map[keyc][combo]) - 1, &len, map[keyc][combo]); if (status != noErr) map[keyc][combo][0] = 0;
@@ -741,14 +740,14 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) second pass, accept matches with diacritical marks. */ for (ignore_diacritics = 0; ignore_diacritics <= 1; ignore_diacritics++) { - for (combo = 0; combo < sizeof(modifier_combos) / sizeof(modifier_combos[0]); combo++) + for (combo = 0; combo < ARRAY_SIZE(modifier_combos); combo++) { for (vkey = 'A'; vkey <= 'Z'; vkey++) { if (vkey_used[vkey]) continue;
- for (keyc = 0; keyc < sizeof(map) / sizeof(map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(map); keyc++) { if (thread_data->keyc2vkey[keyc] || !map[keyc][combo][0]) continue; @@ -767,14 +766,14 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) }
/* Next try to match key codes to the vkeys for the digits 0 through 9. */ - for (combo = 0; combo < sizeof(modifier_combos) / sizeof(modifier_combos[0]); combo++) + for (combo = 0; combo < ARRAY_SIZE(modifier_combos); combo++) { for (vkey = '0'; vkey <= '9'; vkey++) { if (vkey_used[vkey]) continue;
- for (keyc = 0; keyc < sizeof(map) / sizeof(map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(map); keyc++) { if (thread_data->keyc2vkey[keyc] || !map[keyc][combo][0]) continue; @@ -793,16 +792,16 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data)
/* Now try to match key codes for certain common punctuation characters to the most common OEM vkeys (e.g. '.' to VK_OEM_PERIOD). */ - for (i = 0; i < sizeof(symbol_vkeys) / sizeof(symbol_vkeys[0]); i++) + for (i = 0; i < ARRAY_SIZE(symbol_vkeys); i++) { vkey = symbol_vkeys[i].vkey;
if (vkey_used[vkey]) continue;
- for (combo = 0; combo < sizeof(modifier_combos) / sizeof(modifier_combos[0]); combo++) + for (combo = 0; combo < ARRAY_SIZE(modifier_combos); combo++) { - for (keyc = 0; keyc < sizeof(map) / sizeof(map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(map); keyc++) { if (!thread_data->keyc2scan[keyc]) continue; /* not a known Mac key code */ if (thread_data->keyc2vkey[keyc] || !map[keyc][combo][0]) @@ -825,7 +824,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data)
/* For those key codes still without a vkey, try to use the default vkey from the default map, if it's still available. */ - for (keyc = 0; keyc < sizeof(default_map) / sizeof(default_map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(default_map); keyc++) { DWORD vkey = default_map[keyc].vkey;
@@ -844,7 +843,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) map, but whose normal letter vkey wasn't available, try to find a different letter. */ vkey = 'A'; - for (keyc = 0; keyc < sizeof(default_map) / sizeof(default_map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(default_map); keyc++) { if (default_map[keyc].vkey < 'A' || 'Z' < default_map[keyc].vkey) continue; /* not a letter in ANSI layout */ @@ -864,7 +863,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data)
/* Same thing but with the digits. */ vkey = '0'; - for (keyc = 0; keyc < sizeof(default_map) / sizeof(default_map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(default_map); keyc++) { if (default_map[keyc].vkey < '0' || '9' < default_map[keyc].vkey) continue; /* not a digit in ANSI layout */ @@ -885,7 +884,7 @@ void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) /* Last chance. Assign any available vkey. */ vkey_range = 0; vkey = vkey_ranges[vkey_range].first; - for (keyc = 0; keyc < sizeof(default_map) / sizeof(default_map[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(default_map); keyc++) { if (!thread_data->keyc2scan[keyc]) continue; /* not a known Mac key code */ if (thread_data->keyc2vkey[keyc]) continue; /* already assigned */ @@ -1012,7 +1011,7 @@ void macdrv_key_event(HWND hwnd, const macdrv_event *event)
thread_data->last_modifiers = event->key.modifiers;
- if (event->key.keycode < sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0])) + if (event->key.keycode < ARRAY_SIZE(thread_data->keyc2vkey)) { vkey = thread_data->keyc2vkey[event->key.keycode]; scan = thread_data->keyc2scan[event->key.keycode]; @@ -1072,7 +1071,7 @@ void macdrv_hotkey_press(const macdrv_event *event) event->hotkey_press.vkey, event->hotkey_press.mod_flags, event->hotkey_press.keycode, event->hotkey_press.time_ms);
- if (event->hotkey_press.keycode < sizeof(thread_data->keyc2vkey) / sizeof(thread_data->keyc2vkey[0])) + if (event->hotkey_press.keycode < ARRAY_SIZE(thread_data->keyc2vkey)) { WORD scan = thread_data->keyc2scan[event->hotkey_press.keycode]; BYTE keystate[256]; @@ -1144,10 +1143,10 @@ void macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *ke flags &= ~(NX_COMMANDMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK);
/* Find the Mac keycode corresponding to the scan code */ - for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) if (thread_data->keyc2vkey[keyc] == vkey) break;
- if (keyc >= sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0])) + if (keyc >= ARRAY_SIZE(thread_data->keyc2vkey)) return;
TRACE("flags 0x%08x keyc 0x%04x\n", flags, keyc); @@ -1223,7 +1222,7 @@ INT CDECL macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) int scan, keyc;
scan = (lparam >> 16) & 0x1FF; - for (keyc = 0; keyc < sizeof(thread_data->keyc2scan)/sizeof(thread_data->keyc2scan[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2scan); keyc++) { if (thread_data->keyc2scan[keyc] == scan) { @@ -1264,7 +1263,7 @@ INT CDECL macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size)
if (scan & 0x100) vkey |= 0x100;
- for (i = 0; i < sizeof(vkey_names) / sizeof(vkey_names[0]); i++) + for (i = 0; i < ARRAY_SIZE(vkey_names); i++) { if (vkey_names[i].vkey == vkey) { @@ -1382,7 +1381,7 @@ UINT CDECL macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl) }
/* vkey -> keycode -> scan */ - for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) { if (thread_data->keyc2vkey[keyc] == wCode) { @@ -1395,7 +1394,7 @@ UINT CDECL macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl) case MAPVK_VSC_TO_VK: /* scan-code to vkey-code */ case MAPVK_VSC_TO_VK_EX: /* scan -> keycode -> vkey */ - for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) if ((thread_data->keyc2scan[keyc] & 0xFF) == (wCode & 0xFF)) { ret = thread_data->keyc2vkey[keyc]; @@ -1445,10 +1444,10 @@ UINT CDECL macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl) uchr = (const UCKeyboardLayout*)CFDataGetBytePtr(thread_data->keyboard_layout_uchr);
/* Find the Mac keycode corresponding to the vkey */ - for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) if (thread_data->keyc2vkey[keyc] == wCode) break;
- if (keyc >= sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0])) + if (keyc >= ARRAY_SIZE(thread_data->keyc2vkey)) { WARN("Unknown virtual key %X\n", wCode); break; @@ -1458,15 +1457,14 @@ UINT CDECL macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl)
deadKeyState = 0; status = UCKeyTranslate(uchr, keyc, kUCKeyActionDown, 0, - thread_data->keyboard_type, 0, &deadKeyState, - sizeof(s)/sizeof(s[0]), &len, s); + thread_data->keyboard_type, 0, &deadKeyState, ARRAY_SIZE(s), &len, s); if (status == noErr && !len && deadKeyState) { deadKey = TRUE; deadKeyState = 0; status = UCKeyTranslate(uchr, keyc, kUCKeyActionDown, 0, thread_data->keyboard_type, kUCKeyTranslateNoDeadKeysMask, - &deadKeyState, sizeof(s)/sizeof(s[0]), &len, s); + &deadKeyState, ARRAY_SIZE(s), &len, s); }
if (status == noErr && len) @@ -1496,10 +1494,10 @@ BOOL CDECL macdrv_RegisterHotKey(HWND hwnd, UINT mod_flags, UINT vkey) TRACE_(key)("hwnd %p mod_flags 0x%04x vkey 0x%04x\n", hwnd, mod_flags, vkey);
/* Find the Mac keycode corresponding to the vkey */ - for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey) / sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) if (thread_data->keyc2vkey[keyc] == vkey) break;
- if (keyc >= sizeof(thread_data->keyc2vkey) / sizeof(thread_data->keyc2vkey[0])) + if (keyc >= ARRAY_SIZE(thread_data->keyc2vkey)) { WARN_(key)("ignoring unknown virtual key 0x%04x\n", vkey); return TRUE; @@ -1641,10 +1639,10 @@ INT CDECL macdrv_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState modifierKeyState |= (optionKey >> 8);
/* Find the Mac keycode corresponding to the vkey */ - for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) if (thread_data->keyc2vkey[keyc] == virtKey) break;
- if (keyc >= sizeof(thread_data->keyc2vkey)/sizeof(thread_data->keyc2vkey[0])) + if (keyc >= ARRAY_SIZE(thread_data->keyc2vkey)) { WARN_(key)("Unknown virtual key 0x%04x\n", virtKey); goto done; @@ -1780,7 +1778,7 @@ SHORT CDECL macdrv_VkKeyScanEx(WCHAR wChar, HKL hkl) modifierKeyState |= (cmdKey >> 8); }
- for (keyc = 0; keyc < sizeof(thread_data->keyc2vkey) / sizeof(thread_data->keyc2vkey[0]); keyc++) + for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) { UInt32 deadKeyState = 0; UniChar uchar; diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 4bd74112b5..7abeea9db8 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -90,7 +90,7 @@ const char* debugstr_cf(CFTypeRef t) if (!ret) { UniChar buf[200]; - int len = min(CFStringGetLength(s), sizeof(buf)/sizeof(buf[0])); + int len = min(CFStringGetLength(s), ARRAY_SIZE(buf)); CFStringGetCharacters(s, CFRangeMake(0, len), buf); ret = debugstr_wn(buf, len); } @@ -242,7 +242,7 @@ static void load_strings(HINSTANCE instance) return; }
- for (i = 0; i < sizeof(ids) / sizeof(ids[0]); i++) + for (i = 0; i < ARRAY_SIZE(ids); i++) { LPCWSTR str; int len = LoadStringW(instance, ids[i], (LPWSTR)&str, 0); diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 91c5b8895b..a6369c6168 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -225,7 +225,7 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info) }
/* Make sure it's one of the appropriate NSCursor class methods. */ - for (i = 0; i < sizeof(cocoa_cursor_names) / sizeof(cocoa_cursor_names[0]); i++) + for (i = 0; i < ARRAY_SIZE(cocoa_cursor_names); i++) if (CFEqual(cursor_name, cocoa_cursor_names[i])) goto done;
@@ -238,9 +238,9 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info) if (info->szResName[0]) goto done; /* only integer resources are supported here */ if (!(module = GetModuleHandleW(info->szModName))) goto done;
- for (i = 0; i < sizeof(module_cursors)/sizeof(module_cursors[0]); i++) + for (i = 0; i < ARRAY_SIZE(module_cursors); i++) if (GetModuleHandleW(module_cursors[i].name) == module) break; - if (i == sizeof(module_cursors)/sizeof(module_cursors[0])) goto done; + if (i == ARRAY_SIZE(module_cursors)) goto done;
cursors = module_cursors[i].cursors; for (i = 0; cursors[i].id; i++) @@ -276,7 +276,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width, CGPoint hot_spot; CFDictionaryRef hot_spot_dict; const CFStringRef keys[] = { CFSTR("image"), CFSTR("hotSpot") }; - CFTypeRef values[sizeof(keys) / sizeof(keys[0])]; + CFTypeRef values[ARRAY_SIZE(keys)]; CFDictionaryRef frame; CFArrayRef frames;
@@ -444,7 +444,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
values[0] = cgmasked; values[1] = hot_spot_dict; - frame = CFDictionaryCreate(NULL, (const void**)keys, values, sizeof(keys) / sizeof(keys[0]), + frame = CFDictionaryCreate(NULL, (const void**)keys, values, ARRAY_SIZE(keys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFRelease(hot_spot_dict); diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index f11727fe8a..d83a4cea57 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -328,7 +328,7 @@ static const char* debugstr_attrib(int attrib, int value) const char *attrib_name = NULL; const char *value_name = NULL;
- for (i = 0; i < sizeof(attrib_names) / sizeof(attrib_names[0]); i++) + for (i = 0; i < ARRAY_SIZE(attrib_names); i++) { if (attrib_names[i].attrib == attrib) { @@ -386,7 +386,7 @@ static CGOpenGLDisplayMask active_displays_mask(void) uint32_t count, i; CGOpenGLDisplayMask mask;
- err = CGGetActiveDisplayList(sizeof(displays) / sizeof(displays[0]), displays, &count); + err = CGGetActiveDisplayList(ARRAY_SIZE(displays), displays, &count); if (err != kCGErrorSuccess) { displays[0] = CGMainDisplayID(); @@ -473,7 +473,7 @@ static void dump_renderer(const renderer_properties* renderer) TRACE(" Double buffer: %s\n", (renderer->buffer_modes & kCGLDoubleBufferBit) ? "YES" : "NO");
TRACE("Color buffer modes:\n"); - for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(color_modes); i++) { if (renderer->color_modes & color_modes[i].mode) { @@ -485,7 +485,7 @@ static void dump_renderer(const renderer_properties* renderer) }
TRACE("Accumulation buffer sizes: { "); - for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(color_modes); i++) { if (renderer->accum_modes & color_modes[i].mode) TRACE("%d, ", color_modes[i].color_bits); @@ -493,7 +493,7 @@ static void dump_renderer(const renderer_properties* renderer) TRACE("}\n");
TRACE("Depth buffer sizes: { "); - for (i = 0; i < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(depth_stencil_modes); i++) { if (renderer->depth_modes & depth_stencil_modes[i].mode) TRACE("%d, ", depth_stencil_modes[i].bits); @@ -501,7 +501,7 @@ static void dump_renderer(const renderer_properties* renderer) TRACE("}\n");
TRACE("Stencil buffer sizes: { "); - for (i = 0; i < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(depth_stencil_modes); i++) { if (renderer->stencil_modes & depth_stencil_modes[i].mode) TRACE("%d, ", depth_stencil_modes[i].bits); @@ -565,7 +565,7 @@ static unsigned int best_color_mode(GLint modes, GLint color_size, GLint alpha_s int best = -1; int i;
- for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(color_modes); i++) { if ((modes & color_modes[i].mode) && color_modes[i].color_bits >= color_size && @@ -593,7 +593,7 @@ static unsigned int best_color_mode(GLint modes, GLint color_size, GLint alpha_s if (best < 0) { /* Couldn't find a match. Return first one that renderer supports. */ - for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(color_modes); i++) { if (modes & color_modes[i].mode) return i; @@ -609,7 +609,7 @@ static unsigned int best_accum_mode(GLint modes, GLint accum_size) int best = -1; int i;
- for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++) + for (i = 0; i < ARRAY_SIZE(color_modes); i++) { if ((modes & color_modes[i].mode) && color_modes[i].color_bits >= accum_size) { @@ -633,7 +633,7 @@ static unsigned int best_accum_mode(GLint modes, GLint accum_size) if (best < 0) { /* Couldn't find a match. Return last one that renderer supports. */ - for (i = sizeof(color_modes)/sizeof(color_modes[0]) - 1; i >= 0; i--) + for (i = ARRAY_SIZE(color_modes) - 1; i >= 0; i--) { if (modes & color_modes[i].mode) return i; @@ -701,7 +701,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA request.aux_buffers = aux;
n_stack[++n_stack_idx] = n; - for (color_mode = 0; color_mode < sizeof(color_modes)/sizeof(color_modes[0]); color_mode++) + for (color_mode = 0; color_mode < ARRAY_SIZE(color_modes); color_mode++) { unsigned int depth_mode;
@@ -719,7 +719,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA request.color_mode = color_mode;
n_stack[++n_stack_idx] = n; - for (depth_mode = 0; depth_mode < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); depth_mode++) + for (depth_mode = 0; depth_mode < ARRAY_SIZE(depth_stencil_modes); depth_mode++) { unsigned int stencil_mode;
@@ -733,7 +733,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA request.depth_bits = depth_stencil_modes[depth_mode].bits;
n_stack[++n_stack_idx] = n; - for (stencil_mode = 0; stencil_mode < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); stencil_mode++) + for (stencil_mode = 0; stencil_mode < ARRAY_SIZE(depth_stencil_modes); stencil_mode++) { unsigned int stereo;
@@ -767,7 +767,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA
/* Starts at -1 for a 0 accum size */ n_stack[++n_stack_idx] = n; - for (accum_mode = -1; accum_mode < (int)(sizeof(color_modes)/sizeof(color_modes[0])); accum_mode++) + for (accum_mode = -1; accum_mode < (int) ARRAY_SIZE(color_modes); accum_mode++) { unsigned int target_pass;
@@ -4265,7 +4265,7 @@ static BOOL init_opengl(void) return FALSE; }
- for (i = 0; i < sizeof(opengl_func_names)/sizeof(opengl_func_names[0]); i++) + for (i = 0; i < ARRAY_SIZE(opengl_func_names); i++) { if (!(((void **)&opengl_funcs.gl)[i] = wine_dlsym(opengl_handle, opengl_func_names[i], NULL, 0))) { diff --git a/dlls/winemac.drv/systray.c b/dlls/winemac.drv/systray.c index 9351d7796f..a2c32b238f 100644 --- a/dlls/winemac.drv/systray.c +++ b/dlls/winemac.drv/systray.c @@ -147,7 +147,7 @@ static BOOL modify_icon(struct tray_icon *icon, NOTIFYICONDATAW *nid) } if (nid->uFlags & NIF_TIP) { - lstrcpynW(icon->tiptext, nid->szTip, sizeof(icon->tiptext)/sizeof(WCHAR)); + lstrcpynW(icon->tiptext, nid->szTip, ARRAY_SIZE(icon->tiptext)); if (icon->status_item) update_tooltip = TRUE; } diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 6558824bd3..b7a09634ee 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -710,7 +710,7 @@ static void create_cocoa_window(struct macdrv_win_data *data) set_cocoa_window_properties(data);
/* set the window text */ - if (!InternalGetWindowText(data->hwnd, text, sizeof(text)/sizeof(WCHAR))) text[0] = 0; + if (!InternalGetWindowText(data->hwnd, text, ARRAY_SIZE(text))) text[0] = 0; macdrv_set_cocoa_window_title(data->cocoa_window, text, strlenW(text));
/* set the window region */