winex11.drv: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-09-19 21:01:10 +02:00 committed by Alexandre Julliard
parent 54e3a99634
commit 8e1d40b966
9 changed files with 20 additions and 20 deletions

View File

@ -169,7 +169,7 @@ static Pixmap BRUSH_DitherMono( COLORREF color )
{ 0x1, 0x3 }, /* LTGRAY */ { 0x1, 0x3 }, /* LTGRAY */
}; };
int gray = (30 * GetRValue(color) + 59 * GetGValue(color) + 11 * GetBValue(color)) / 100; int gray = (30 * GetRValue(color) + 59 * GetGValue(color) + 11 * GetBValue(color)) / 100;
int idx = gray * (sizeof gray_dither/sizeof gray_dither[0] + 1)/256 - 1; int idx = gray * (ARRAY_SIZE( gray_dither ) + 1)/256 - 1;
TRACE("color=%06x -> gray=%x\n", color, gray); TRACE("color=%06x -> gray=%x\n", color, gray);
return XCreateBitmapFromData( gdi_display, root_window, gray_dither[idx], 2, 2 ); return XCreateBitmapFromData( gdi_display, root_window, gray_dither[idx], 2, 2 );

View File

@ -1933,12 +1933,12 @@ static LRESULT CALLBACK clipboard_wndproc( HWND hwnd, UINT msg, WPARAM wp, LPARA
static BOOL wait_clipboard_mutex(void) static BOOL wait_clipboard_mutex(void)
{ {
static const WCHAR prefix[] = {'_','_','w','i','n','e','_','c','l','i','p','b','o','a','r','d','_'}; 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; HANDLE mutex;
memcpy( buffer, prefix, sizeof(prefix) ); memcpy( buffer, prefix, sizeof(prefix) );
if (!GetUserObjectInformationW( GetProcessWindowStation(), UOI_NAME, if (!GetUserObjectInformationW( GetProcessWindowStation(), UOI_NAME,
buffer + sizeof(prefix) / sizeof(WCHAR), buffer + ARRAY_SIZE( prefix ),
sizeof(buffer) - sizeof(prefix), NULL )) sizeof(buffer) - sizeof(prefix), NULL ))
{ {
ERR( "failed to get winstation name\n" ); ERR( "failed to get winstation name\n" );

View File

@ -1739,7 +1739,7 @@ static BOOL X11DRV_ClientMessage( HWND hwnd, XEvent *xev )
return FALSE; return FALSE;
} }
for (i = 0; i < sizeof(client_messages)/sizeof(client_messages[0]); i++) for (i = 0; i < ARRAY_SIZE( client_messages ); i++)
{ {
if (event->message_type == X11DRV_Atoms[client_messages[i].atom - FIRST_XATOM]) if (event->message_type == X11DRV_Atoms[client_messages[i].atom - FIRST_XATOM])
{ {

View File

@ -1644,7 +1644,7 @@ BOOL X11DRV_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
'P','r','o','f','i','l','e','.','i','c','m',0}; 'P','r','o','f','i','l','e','.','i','c','m',0};
HKEY hkey; HKEY hkey;
DWORD required, len; DWORD required, len;
WCHAR profile[MAX_PATH], fullname[2*MAX_PATH + sizeof(color_path)/sizeof(WCHAR)]; WCHAR profile[MAX_PATH], fullname[2*MAX_PATH + ARRAY_SIZE( color_path )];
unsigned char *buffer; unsigned char *buffer;
unsigned long buflen; unsigned long buflen;
@ -1653,7 +1653,7 @@ BOOL X11DRV_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
GetSystemDirectoryW( fullname, MAX_PATH ); GetSystemDirectoryW( fullname, MAX_PATH );
strcatW( fullname, color_path ); strcatW( fullname, color_path );
len = sizeof(profile)/sizeof(WCHAR); len = ARRAY_SIZE( profile );
if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, mntr_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL ) && if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, mntr_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL ) &&
!RegEnumValueW( hkey, 0, profile, &len, NULL, NULL, NULL, NULL )) /* FIXME handle multiple values */ !RegEnumValueW( hkey, 0, profile, &len, NULL, NULL, NULL, NULL )) /* FIXME handle multiple values */
{ {
@ -1726,7 +1726,7 @@ INT X11DRV_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW proc, LPARAM lparam )
return -1; return -1;
len_sysdir = GetSystemDirectoryW( sysdir, MAX_PATH ); len_sysdir = GetSystemDirectoryW( sysdir, MAX_PATH );
len_path = len_sysdir + sizeof(color_path) / sizeof(color_path[0]) - 1; len_path = len_sysdir + ARRAY_SIZE( color_path ) - 1;
len = 64; len = 64;
for (;;) for (;;)
{ {

View File

@ -986,7 +986,7 @@ static int find_fallback_shape( const char *name )
{ {
struct cursor_font_fallback *fallback; struct cursor_font_fallback *fallback;
if ((fallback = bsearch( name, fallbacks, sizeof(fallbacks) / sizeof(fallbacks[0]), if ((fallback = bsearch( name, fallbacks, ARRAY_SIZE( fallbacks ),
sizeof(*fallback), fallback_cmp ))) sizeof(*fallback), fallback_cmp )))
return fallback->shape; return fallback->shape;
return -1; return -1;
@ -1038,9 +1038,9 @@ static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
if (info->szResName[0]) goto done; /* only integer resources are supported here */ if (info->szResName[0]) goto done; /* only integer resources are supported here */
if (!(module = GetModuleHandleW( info->szModName ))) goto done; 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 (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; cursors = module_cursors[i].cursors;
for (i = 0; cursors[i].id; i++) for (i = 0; cursors[i].id; i++)

View File

@ -555,7 +555,7 @@ static BOOL WINAPI init_opengl( INIT_ONCE *once, void *param, void **context )
return TRUE; return TRUE;
} }
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 ))) if (!(((void **)&opengl_funcs.gl)[i] = wine_dlsym( opengl_handle, opengl_func_names[i], NULL, 0 )))
{ {

View File

@ -108,27 +108,27 @@ HPEN X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *patte
switch(logpen.lopnStyle & PS_STYLE_MASK) switch(logpen.lopnStyle & PS_STYLE_MASK)
{ {
case PS_DASH: case PS_DASH:
physDev->pen.dash_len = sizeof(PEN_dash)/sizeof(*PEN_dash); physDev->pen.dash_len = ARRAY_SIZE( PEN_dash );
memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dash : PEN_dash, memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dash : PEN_dash,
physDev->pen.dash_len); physDev->pen.dash_len);
break; break;
case PS_DOT: case PS_DOT:
physDev->pen.dash_len = sizeof(PEN_dot)/sizeof(*PEN_dot); physDev->pen.dash_len = ARRAY_SIZE( PEN_dot );
memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dot : PEN_dot, memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dot : PEN_dot,
physDev->pen.dash_len); physDev->pen.dash_len);
break; break;
case PS_DASHDOT: case PS_DASHDOT:
physDev->pen.dash_len = sizeof(PEN_dashdot)/sizeof(*PEN_dashdot); physDev->pen.dash_len = ARRAY_SIZE( PEN_dashdot );
memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dashdot : PEN_dashdot, memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dashdot : PEN_dashdot,
physDev->pen.dash_len); physDev->pen.dash_len);
break; break;
case PS_DASHDOTDOT: case PS_DASHDOTDOT:
physDev->pen.dash_len = sizeof(PEN_dashdotdot)/sizeof(*PEN_dashdotdot); physDev->pen.dash_len = ARRAY_SIZE( PEN_dashdotdot );
memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dashdotdot : PEN_dashdotdot, memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dashdotdot : PEN_dashdotdot,
physDev->pen.dash_len); physDev->pen.dash_len);
break; break;
case PS_ALTERNATE: case PS_ALTERNATE:
physDev->pen.dash_len = sizeof(PEN_alternate)/sizeof(*PEN_alternate); physDev->pen.dash_len = ARRAY_SIZE( PEN_alternate );
memcpy(physDev->pen.dashes, PEN_alternate, physDev->pen.dash_len); memcpy(physDev->pen.dashes, PEN_alternate, physDev->pen.dash_len);
break; break;
case PS_USERSTYLE: case PS_USERSTYLE:

View File

@ -772,13 +772,13 @@ static BOOL modify_icon( struct tray_icon *icon, NOTIFYICONDATAW *nid )
} }
if (nid->uFlags & NIF_TIP) 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->tooltip) update_tooltip_text(icon); if (icon->tooltip) update_tooltip_text(icon);
} }
if (nid->uFlags & NIF_INFO && nid->cbSize >= NOTIFYICONDATAA_V2_SIZE) if (nid->uFlags & NIF_INFO && nid->cbSize >= NOTIFYICONDATAA_V2_SIZE)
{ {
lstrcpynW( icon->info_text, nid->szInfo, sizeof(icon->info_text)/sizeof(WCHAR) ); lstrcpynW( icon->info_text, nid->szInfo, ARRAY_SIZE( icon->info_text ));
lstrcpynW( icon->info_title, nid->szInfoTitle, sizeof(icon->info_title)/sizeof(WCHAR) ); lstrcpynW( icon->info_title, nid->szInfoTitle, ARRAY_SIZE( icon->info_title ));
icon->info_flags = nid->dwInfoFlags; icon->info_flags = nid->dwInfoFlags;
icon->info_timeout = max(min(nid->u.uTimeout, BALLOON_SHOW_MAX_TIMEOUT), BALLOON_SHOW_MIN_TIMEOUT); icon->info_timeout = max(min(nid->u.uTimeout, BALLOON_SHOW_MAX_TIMEOUT), BALLOON_SHOW_MIN_TIMEOUT);
icon->info_icon = nid->hBalloonIcon; icon->info_icon = nid->hBalloonIcon;

View File

@ -1530,7 +1530,7 @@ static void create_whole_window( struct x11drv_win_data *data )
SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window ); SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
/* set the window text */ /* 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;
sync_window_text( data->display, data->whole_window, text ); sync_window_text( data->display, data->whole_window, text );
/* set the window region */ /* set the window region */