Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- dlls/user32/class.c | 12 ++++++------ dlls/user32/dialog.c | 4 ++-- dlls/user32/exticon.c | 4 ++-- dlls/user32/mdi.c | 8 ++++---- dlls/user32/menu.c | 2 +- dlls/user32/message.c | 4 ++-- dlls/user32/msgbox.c | 2 +- dlls/user32/nonclient.c | 4 ++-- dlls/user32/spy.c | 11 +++++------ dlls/user32/sysparams.c | 7 +++---- dlls/user32/text.c | 2 +- dlls/user32/win.c | 4 ++-- 12 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c index a8b5a8fe5c..d4e7951d39 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -150,7 +150,7 @@ static BOOL is_comctl32_class( const WCHAR *name ) {'t','o','o','l','t','i','p','s','_','c','l','a','s','s','3','2',0}, };
- int min = 0, max = (sizeof(classesW) / sizeof(classesW[0])) - 1; + int min = 0, max = ARRAY_SIZE( classesW ) - 1;
while (min <= max) { @@ -171,7 +171,7 @@ static BOOL is_builtin_class( const WCHAR *name ) {'S','c','r','o','l','l','b','a','r',0}, };
- int min = 0, max = (sizeof(classesW) / sizeof(classesW[0])) - 1; + int min = 0, max = ARRAY_SIZE( classesW ) - 1;
while (min <= max) { @@ -473,7 +473,7 @@ static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE strcpyW( classPtr->name, name ); classPtr->basename += basename_offset; } - else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, sizeof(classPtr->name)/sizeof(WCHAR) ); + else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, ARRAY_SIZE( classPtr->name ));
SERVER_START_REQ( create_class ) { @@ -1125,7 +1125,7 @@ static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval, if (!set_server_info( hwnd, offset, newval, size )) break; retval = class->atomName; class->atomName = newval; - GlobalGetAtomNameW( newval, class->name, sizeof(class->name)/sizeof(WCHAR) ); + GlobalGetAtomNameW( newval, class->name, ARRAY_SIZE( class->name )); break; case GCL_CBCLSEXTRA: /* cannot change this one */ SetLastError( ERROR_INVALID_PARAMETER ); @@ -1166,7 +1166,7 @@ INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count ) DWORD len;
if (count <= 0) return 0; - if (!GetClassNameW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0; + if (!GetClassNameW( hwnd, tmpbuf, ARRAY_SIZE( tmpbuf ))) return 0; RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) ); buffer[len] = 0; return len; @@ -1299,7 +1299,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc ) if (!IS_INTRESOURCE(name)) { WCHAR nameW[MAX_ATOM_LEN + 1]; - if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) )) + if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW ))) return FALSE; classPtr = CLASS_FindClass( nameW, hInstance ); } diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index 46220b0de7..7d1f6b3de7 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -960,7 +960,7 @@ static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM wParam ) { dlgCode = SendMessageW( hwndControl, WM_GETDLGCODE, 0, 0 ); if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) && - GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) )) + GetWindowTextW( hwndControl, buffer, ARRAY_SIZE( buffer ))) { /* find the accelerator key */ LPWSTR p = buffer - 2; @@ -1868,7 +1868,7 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0)) { WCHAR temp[MAX_PATH]; - GetCurrentDirectoryW( sizeof(temp)/sizeof(WCHAR), temp ); + GetCurrentDirectoryW( ARRAY_SIZE( temp ), temp ); CharLowerW( temp ); /* Can't use PostMessage() here, because the string is on the stack */ SetDlgItemTextW( hDlg, idStatic, temp ); diff --git a/dlls/user32/exticon.c b/dlls/user32/exticon.c index a428ae70c6..a16ae522c7 100644 --- a/dlls/user32/exticon.c +++ b/dlls/user32/exticon.c @@ -286,8 +286,8 @@ static UINT ICO_ExtractIconExW(
TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId, flags);
- dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL); - if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0]))) + dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, ARRAY_SIZE(szExePath), szExePath, NULL); + if ((dwSearchReturn == 0) || (dwSearchReturn > ARRAY_SIZE(szExePath))) { WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName)); return -1; diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c index ea362585a6..f990335d88 100644 --- a/dlls/user32/mdi.c +++ b/dlls/user32/mdi.c @@ -437,7 +437,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
if (visible == MDI_MOREWINDOWSLIMIT) { - LoadStringW(user32_module, IDS_MDI_MOREWINDOWS, buf, sizeof(buf)/sizeof(WCHAR)); + LoadStringW(user32_module, IDS_MDI_MOREWINDOWS, buf, ARRAY_SIZE(buf)); AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf); break; } @@ -453,7 +453,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci) buf[0] = '&'; buf[1] = '0' + visible; buf[2] = ' '; - InternalGetWindowText(ci->child[i], buf + 3, sizeof(buf)/sizeof(WCHAR) - 3); + InternalGetWindowText(ci->child[i], buf + 3, ARRAY_SIZE(buf) - 3); TRACE("Adding %p, id %u %s\n", ci->child[i], id, debugstr_w(buf)); AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
@@ -979,7 +979,7 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, BOOL repaint, LPCWSTR
if (!lpTitle && !ci->frameTitle) /* first time around, get title from the frame window */ { - GetWindowTextW( frame, lpBuffer, sizeof(lpBuffer)/sizeof(WCHAR) ); + GetWindowTextW( frame, lpBuffer, ARRAY_SIZE( lpBuffer )); lpTitle = lpBuffer; }
@@ -1910,7 +1910,7 @@ static INT_PTR WINAPI MDI_MoreWindowsDlgProc (HWND hDlg, UINT iMsg, WPARAM wPara { WCHAR buffer[MDI_MAXTITLELENGTH];
- if (!InternalGetWindowText( ci->child[i], buffer, sizeof(buffer)/sizeof(WCHAR) )) + if (!InternalGetWindowText(ci->child[i], buffer, ARRAY_SIZE(buffer))) continue; SendMessageW(hListBox, LB_ADDSTRING, 0, (LPARAM)buffer ); SendMessageW(hListBox, LB_SETITEMDATA, i, (LPARAM)ci->child[i] ); diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index f4194ed6f2..99a99c0395 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -5510,7 +5510,7 @@ INT WINAPI TranslateAcceleratorW( HWND hWnd, HACCEL hAccel, LPMSG msg ) hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam);
if (!(count = CopyAcceleratorTableW( hAccel, NULL, 0 ))) return 0; - if (count > sizeof(data)/sizeof(data[0])) + if (count > ARRAY_SIZE( data )) { if (!(ptr = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ptr) ))) return 0; } diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 6b7f91854f..d2e6a75726 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -2312,7 +2312,7 @@ static BOOL process_rawinput_message( MSG *msg, const struct hardware_msg_data * rawinput->data.mouse.usFlags = MOUSE_MOVE_RELATIVE; rawinput->data.mouse.u.s.usButtonFlags = 0; rawinput->data.mouse.u.s.usButtonData = 0; - for (i = 1; i < sizeof(button_flags) / sizeof(*button_flags); ++i) + for (i = 1; i < ARRAY_SIZE(button_flags); ++i) { if (msg_data->flags & (1 << i)) rawinput->data.mouse.u.s.usButtonFlags |= button_flags[i]; @@ -3902,7 +3902,7 @@ BOOL WINAPI TranslateMessage( const MSG *msg ) }
GetKeyboardState( state ); - len = ToUnicode(msg->wParam, HIWORD(msg->lParam), state, wp, sizeof(wp)/sizeof(WCHAR), 0); + len = ToUnicode(msg->wParam, HIWORD(msg->lParam), state, wp, ARRAY_SIZE(wp), 0); if (len == -1) { message = (msg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR; diff --git a/dlls/user32/msgbox.c b/dlls/user32/msgbox.c index d3d11d6ceb..457c3ae7d1 100644 --- a/dlls/user32/msgbox.c +++ b/dlls/user32/msgbox.c @@ -294,7 +294,7 @@ static void MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb)
/* Position the buttons */ bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2; - for (buttons = i = 0; i < (sizeof(buttonOrder) / sizeof(buttonOrder[0])); i++) { + for (buttons = i = 0; i < ARRAY_SIZE(buttonOrder); i++) {
/* Convert the button order to ID* value to order for the buttons */ hItem = GetDlgItem(hwnd, buttonOrder[i]); diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c index 2b38897729..fcf32f01ef 100644 --- a/dlls/user32/nonclient.c +++ b/dlls/user32/nonclient.c @@ -343,7 +343,7 @@ BOOL WINAPI DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
if (!str) { - if (!GetWindowTextW( hwnd, text, sizeof(text)/sizeof(WCHAR) )) text[0] = 0; + if (!GetWindowTextW( hwnd, text, ARRAY_SIZE( text ))) text[0] = 0; str = text; } rc.left += 2; @@ -953,7 +953,7 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, DWORD style, } }
- if (GetWindowTextW( hwnd, buffer, sizeof(buffer)/sizeof(WCHAR) )) + if (GetWindowTextW( hwnd, buffer, ARRAY_SIZE( buffer ))) { NONCLIENTMETRICSW nclm; HFONT hFont, hOldFont; diff --git a/dlls/user32/spy.c b/dlls/user32/spy.c index 80bd0a3133..749fc220b4 100644 --- a/dlls/user32/spy.c +++ b/dlls/user32/spy.c @@ -2127,7 +2127,7 @@ const char *SPY_GetClassLongOffsetName( INT offset ) { INT index; if (offset < 0 && offset % 2 == 0 && ((index = -(offset + 8) / 2) < - sizeof(ClassLongOffsetNames) / sizeof(*ClassLongOffsetNames))) + ARRAY_SIZE(ClassLongOffsetNames))) { return ClassLongOffsetNames[index]; } @@ -2148,7 +2148,7 @@ static void SPY_GetClassName( SPY_INSTANCE *sp_e ) strcpyW(sp_e->wnd_class, WC_PROPSHEETW); } else { - GetClassNameW(sp_e->msg_hwnd, sp_e->wnd_class, sizeof(sp_e->wnd_class)/sizeof(WCHAR)); + GetClassNameW(sp_e->msg_hwnd, sp_e->wnd_class, ARRAY_SIZE(sp_e->wnd_class)); } }
@@ -2223,12 +2223,12 @@ static void SPY_GetWndName( SPY_INSTANCE *sp_e )
SPY_GetClassName( sp_e );
- len = InternalGetWindowText(sp_e->msg_hwnd, sp_e->wnd_name, sizeof(sp_e->wnd_name)/sizeof(WCHAR)); + len = InternalGetWindowText(sp_e->msg_hwnd, sp_e->wnd_name, ARRAY_SIZE(sp_e->wnd_name)); if(!len) /* get class name */ { LPWSTR dst = sp_e->wnd_name; LPWSTR src = sp_e->wnd_class; - int n = sizeof(sp_e->wnd_name)/sizeof(WCHAR) - 3; + int n = ARRAY_SIZE(sp_e->wnd_name) - 3; *dst++ = '{'; while ((n-- > 0) && *src) *dst++ = *src++; *dst++ = '}'; @@ -2537,8 +2537,7 @@ static void SPY_DumpStructure(const SPY_INSTANCE *sp_e, BOOL enter) if (pnmh->code == NM_CUSTOMDRAW) { /* save and restore error code over the next call */ save_error = GetLastError(); - GetClassNameW(pnmh->hwndFrom, from_class, - sizeof(from_class)/sizeof(WCHAR)); + GetClassNameW(pnmh->hwndFrom, from_class, ARRAY_SIZE(from_class)); SetLastError(save_error); if (strcmpW(TOOLBARCLASSNAMEW, from_class) == 0) dumplen = sizeof(NMTBCUSTOMDRAW)-sizeof(NMHDR); diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 2fcf2fbfea..7780293490 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -1383,7 +1383,7 @@ void SYSPARAMS_Init(void)
if (volatile_base_key && dispos == REG_CREATED_NEW_KEY) /* first process, initialize entries */ { - for (i = 0; i < sizeof(default_entries)/sizeof(default_entries[0]); i++) + for (i = 0; i < ARRAY_SIZE( default_entries ); i++) default_entries[i]->hdr.init( default_entries[i] ); } } @@ -2251,9 +2251,8 @@ BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam, { WCHAR buffer[256]; if (pvParam) - if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer, - sizeof(buffer)/sizeof(WCHAR) )) - buffer[sizeof(buffer)/sizeof(WCHAR)-1] = 0; + if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer, ARRAY_SIZE( buffer ))) + buffer[ARRAY_SIZE(buffer)-1] = 0; ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni ); break; } diff --git a/dlls/user32/text.c b/dlls/user32/text.c index 2ac3afd607..0b5bd47461 100644 --- a/dlls/user32/text.c +++ b/dlls/user32/text.c @@ -970,7 +970,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
do { - len = sizeof(line)/sizeof(line[0]); + len = ARRAY_SIZE(line); if (invert_y) last_line = !(flags & DT_NOCLIP) && y - ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) < rect->bottom; else diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 3c497f878e..019b178f95 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -1748,7 +1748,7 @@ HWND WINAPI DECLSPEC_HOTPATCH CreateWindowExA( DWORD exStyle, LPCSTR className, if (!IS_INTRESOURCE(className)) { WCHAR bufferW[256]; - if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) )) + if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, ARRAY_SIZE( bufferW ))) return 0; return wow_handlers.create_window( (CREATESTRUCTW *)&cs, bufferW, instance, FALSE ); } @@ -2024,7 +2024,7 @@ HWND WINAPI FindWindowExA( HWND parent, HWND child, LPCSTR className, LPCSTR tit if (!IS_INTRESOURCE(className)) { WCHAR classW[256]; - if (MultiByteToWideChar( CP_ACP, 0, className, -1, classW, sizeof(classW)/sizeof(WCHAR) )) + if (MultiByteToWideChar( CP_ACP, 0, className, -1, classW, ARRAY_SIZE( classW ))) hwnd = FindWindowExW( parent, child, classW, titleW ); } else