Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/user32/tests/class.c | 16 ++++++-------
dlls/user32/tests/clipboard.c | 4 ++--
dlls/user32/tests/combo.c | 4 ++--
dlls/user32/tests/cursoricon.c | 2 +-
dlls/user32/tests/dde.c | 12 +++++-----
dlls/user32/tests/dialog.c | 8 +++----
dlls/user32/tests/edit.c | 6 ++---
dlls/user32/tests/input.c | 13 +++++------
dlls/user32/tests/listbox.c | 2 +-
dlls/user32/tests/menu.c | 19 ++++++++-------
dlls/user32/tests/monitor.c | 6 ++---
dlls/user32/tests/msg.c | 26 ++++++++++-----------
dlls/user32/tests/resource.c | 4 ++--
dlls/user32/tests/scroll.c | 2 +-
dlls/user32/tests/sysparams.c | 50 ++++++++++++++++++++--------------------
dlls/user32/tests/text.c | 8 +++----
dlls/user32/tests/uitools.c | 2 +-
dlls/user32/tests/win.c | 52 +++++++++++++++++++++---------------------
dlls/user32/tests/wsprintf.c | 8 +++----
19 files changed, 121 insertions(+), 123 deletions(-)
diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c
index 9b3b2b30f3..53fa2f12e3 100644
--- a/dlls/user32/tests/class.c
+++ b/dlls/user32/tests/class.c
@@ -169,7 +169,7 @@ static void ClassTest(HINSTANCE hInstance, BOOL global)
}
/* check GetClassName */
- i = GetClassNameW(hTestWnd, str, sizeof(str)/sizeof(str[0]));
+ i = GetClassNameW(hTestWnd, str, ARRAY_SIZE(str));
ok(i == lstrlenW(className),
"GetClassName returned incorrect length\n");
ok(!lstrcmpW(className,str),
@@ -725,7 +725,7 @@ static void test_builtinproc(void)
ok(IsWindowUnicode(hwnd) ||
broken(!IsWindowUnicode(hwnd)) /* Windows 8 and 10 */,
"Windows should be Unicode\n");
- SendMessageW(hwnd, WM_GETTEXT, sizeof(buf) / sizeof(buf[0]), (LPARAM)buf);
+ SendMessageW(hwnd, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf);
if (IsWindowUnicode(hwnd))
ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
else
@@ -939,7 +939,7 @@ static const struct
static void test_extra_values(void)
{
int i;
- for(i=0; i< sizeof(extra_values)/sizeof(extra_values[0]); i++)
+ for(i = 0; i < ARRAY_SIZE(extra_values); i++)
{
WNDCLASSEXA wcx;
BOOL ret = GetClassInfoExA(NULL,extra_values[i].name,&wcx);
@@ -1133,7 +1133,7 @@ static void test_comctl32_class( const char *name )
name++;
- GetTempPathA(sizeof(path)/sizeof(path[0]), path);
+ GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, "comctl32_class.manifest");
create_manifest_file(path, comctl32_manifest);
@@ -1161,7 +1161,7 @@ static void test_comctl32_class( const char *name )
if (!ret)
goto skiptest;
- MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW));
ret = GetClassInfoW( 0, nameW, &wcW );
ok( ret, "GetClassInfoW failed for %s\n", name );
module = GetModuleHandleA( "comctl32" );
@@ -1187,7 +1187,7 @@ static void test_comctl32_class( const char *name )
ret = GetClassInfoA( 0, name, &wcA );
ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name );
if (!ret) return;
- MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW));
ret = GetClassInfoW( 0, nameW, &wcW );
ok( ret, "GetClassInfoW failed for %s\n", name );
module = GetModuleHandleA( "comctl32" );
@@ -1243,7 +1243,7 @@ static void test_comctl32_classes(void)
};
winetest_get_mainargs( &argv );
- for (i = 0; i < sizeof(classes) / sizeof(classes[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(classes); i++)
{
memset( &startup, 0, sizeof(startup) );
startup.cb = sizeof( startup );
@@ -1322,7 +1322,7 @@ static void test_actctx_classes(void)
HWND hwnd;
char path[MAX_PATH];
- GetTempPathA(sizeof(path)/sizeof(path[0]), path);
+ GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, "actctx_classes.manifest");
create_manifest_file(path, main_manifest);
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
index 3d3ef8b4c1..4436ece70d 100644
--- a/dlls/user32/tests/clipboard.c
+++ b/dlls/user32/tests/clipboard.c
@@ -711,7 +711,7 @@ static void test_synthesized(void)
r = CloseClipboard();
ok(r, "gle %d\n", GetLastError());
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
r = OpenClipboard(NULL);
ok(r, "%u: gle %d\n", i, GetLastError());
@@ -2044,7 +2044,7 @@ static void test_string_data(void)
char bufferA[12];
WCHAR bufferW[12];
- for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(test_data); i++)
{
/* 1-byte Unicode strings crash on Win64 */
#ifdef _WIN64
diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c
index ad706ea754..3358e846a0 100644
--- a/dlls/user32/tests/combo.c
+++ b/dlls/user32/tests/combo.c
@@ -291,7 +291,7 @@ static void test_WM_LBUTTONDOWN(void)
hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|CBS_DROPDOWN,
0, 0, 200, 150, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
- for (i = 0; i < sizeof(choices)/sizeof(UINT); i++){
+ for (i = 0; i < ARRAY_SIZE(choices); i++){
sprintf(buffer, stringFormat, choices[i]);
result = SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)buffer);
ok(result == i,
@@ -709,7 +709,7 @@ static void test_listbox_size(DWORD style)
{10, 100, TRUE},
};
- for(test = 0; test < sizeof(info_height) / sizeof(info_height[0]); test++)
+ for(test = 0; test < ARRAY_SIZE(info_height); test++)
{
const struct list_size_info *info_test = &info_height[test];
int height_item; /* Height of a list item */
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index 3d56815848..8404ee71ab 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -2533,7 +2533,7 @@ static void test_PrivateExtractIcons(void)
static const test_icon_entries_t icon_desc[] = {{0,0,TRUE}, {16,16,TRUE}, {32,32}, {64,64,TRUE}};
- create_ico_file("extract.ico", icon_desc, sizeof(icon_desc)/sizeof(*icon_desc));
+ create_ico_file("extract.ico", icon_desc, ARRAY_SIZE(icon_desc));
ret = PrivateExtractIconsA("extract.ico", 0, 32, 32, &icon, NULL, 1, 0);
ok(ret == 1, "PrivateExtractIconsA returned %u\n", ret);
diff --git a/dlls/user32/tests/dde.c b/dlls/user32/tests/dde.c
index d63a0f65aa..eed2ac437e 100644
--- a/dlls/user32/tests/dde.c
+++ b/dlls/user32/tests/dde.c
@@ -2396,7 +2396,7 @@ static WCHAR test_cmd_w_to_w[][32] = {
{ 0x4efa, 0x4efc, 0x0061, 0x4efe, 0 }, /* some Chinese chars */
{ 0x0061, 0x0062, 0x0063, 0x9152, 0 }, /* Chinese with latin characters begin */
};
-static const int nb_callbacks = 5 + sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]);
+static const int nb_callbacks = 5 + ARRAY_SIZE(test_cmd_w_to_w);
static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv,
HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
@@ -2480,7 +2480,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
size_a = strlen(test_cmd_a_to_a) + 1;
size_w = (lstrlenW(cmd_w) + 1) * sizeof(WCHAR);
size_a_to_w = MultiByteToWideChar( CP_ACP, 0, test_cmd_a_to_a, -1, test_cmd_a_to_w,
- sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR);
+ ARRAY_SIZE(test_cmd_a_to_w)) * sizeof(WCHAR);
size_w_to_a = WideCharToMultiByte( CP_ACP, 0, cmd_w, -1,
test_cmd_w_to_a, sizeof(test_cmd_w_to_a), NULL, NULL );
switch (str_index)
@@ -2528,7 +2528,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
/* double A->W mapping */
/* NT uses the full size, XP+ only until the first null */
DWORD nt_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, size_w, test_cmd_a_to_w,
- sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR);
+ ARRAY_SIZE(test_cmd_a_to_w)) * sizeof(WCHAR);
DWORD xp_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, -1, NULL, 0 ) * sizeof(WCHAR);
ok(size == xp_size || broken(size == nt_size) ||
broken(str_index == 4 && IsDBCSLeadByte(cmd_w[0])) /* East Asian */,
@@ -2554,7 +2554,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
{
todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index);
MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w,
- sizeof(test_cmd_a_to_w)/sizeof(WCHAR));
+ ARRAY_SIZE(test_cmd_a_to_w));
todo_wine ok(!lstrcmpW((WCHAR*)buffer, cmd_w),
"Expected %s got %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), wine_dbgstr_w((WCHAR *)buffer), msg_index);
}
@@ -2562,7 +2562,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
{
todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index);
MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w,
- sizeof(test_cmd_a_to_w)/sizeof(WCHAR));
+ ARRAY_SIZE(test_cmd_a_to_w));
if (!is_cjk())
todo_wine ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w), "Expected %s, got %s, msg_index=%d\n",
wine_dbgstr_w(test_cmd_a_to_w), wine_dbgstr_w((WCHAR*)buffer), msg_index);
@@ -2663,7 +2663,7 @@ static void test_end_to_end_client(BOOL type_a)
err = DdeGetLastError(client_pid);
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
- for (i = 0; i < sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(test_cmd_w_to_w); i++)
{
hdata = DdeClientTransaction((LPBYTE)test_cmd_w_to_w[i],
(lstrlenW(test_cmd_w_to_w[i]) + 1) * sizeof(WCHAR),
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index ab3eec88bc..807a85b4ea 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -161,7 +161,7 @@ static BOOL CreateWindows (HINSTANCE hinst)
*/
if (p->id >= numwnds)
{
- if (p->id >= sizeof(hwnd)/sizeof(hwnd[0]))
+ if (p->id >= ARRAY_SIZE(hwnd))
{
trace ("Control %ld is out of range\n", p->id);
return FALSE;
@@ -1045,7 +1045,7 @@ static void test_GetDlgItemText(void)
BOOL ret;
strcpy(string, "Overwrite Me");
- ret = GetDlgItemTextA(NULL, 0, string, sizeof(string)/sizeof(string[0]));
+ ret = GetDlgItemTextA(NULL, 0, string, ARRAY_SIZE(string));
ok(!ret, "GetDlgItemText(NULL) shouldn't have succeeded\n");
ok(string[0] == '\0' || broken(!strcmp(string, "Overwrite Me")),
@@ -1461,7 +1461,7 @@ static INT_PTR CALLBACK test_aw_conversion_dlgproc(HWND hdlg, UINT msg, WPARAM w
(BYTE)buff[0], (BYTE)buff[1], len);
memset(buffW, 0xff, sizeof(buffW));
- len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0]));
+ len = GetWindowTextW(hdlg, buffW, ARRAY_SIZE(buffW));
ok(buffW[0] == 'W' && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n",
buffW[0], buffW[1], len);
@@ -1567,7 +1567,7 @@ static INT_PTR CALLBACK test_aw_conversion_dlgproc2(HWND hdlg, UINT msg, WPARAM
ok(!strcmp(buff, testtext) && len == 0, "Unexpected window text %s, len %d\n", buff, len);
memset(buffW, 0xff, sizeof(buffW));
- len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0]));
+ len = GetWindowTextW(hdlg, buffW, ARRAY_SIZE(buffW));
ok(buffW[0] == 0 && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n",
buffW[0], buffW[1], len);
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 01418bf551..00c05fdef0 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -2956,7 +2956,7 @@ static void test_EM_GETLINE(void)
hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
hwnd[1] = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
- for (i = 0; i < sizeof(hwnd)/sizeof(hwnd[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(hwnd); i++)
{
static const WCHAR strW[] = {'t','e','x','t',0};
static const char *str = "text";
@@ -2984,13 +2984,13 @@ static void test_EM_GETLINE(void)
ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff);
memset(buffW, 0, sizeof(buffW));
- *(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]);
+ *(WORD *)buffW = ARRAY_SIZE(buffW);
r = SendMessageW(hwnd[i], EM_GETLINE, 0, (LPARAM)buffW);
ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r);
ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
memset(buffW, 0, sizeof(buffW));
- *(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]);
+ *(WORD *)buffW = ARRAY_SIZE(buffW);
r = SendMessageW(hwnd[i], EM_GETLINE, 1, (LPARAM)buffW);
ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r);
ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 8fa1de23e1..03b84007b1 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -943,8 +943,7 @@ static void test_Input_blackbox(void)
i.u.ki.time = 0;
i.u.ki.dwExtraInfo = 0;
- for (ii = 0; ii < sizeof(sendinput_test)/sizeof(struct sendinput_test_s)-1;
- ii++) {
+ for (ii = 0; ii < ARRAY_SIZE(sendinput_test)-1; ii++) {
GetKeyboardState(ks1);
i.u.ki.wScan = ii+1 /* useful for debugging */;
i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
@@ -1520,12 +1519,12 @@ static void test_GetRawInputDeviceList(void)
ok(ret > 0, "expected non-zero\n");
/* check if variable changes from larger to smaller value */
- devcount = odevcount = sizeof(devices) / sizeof(devices[0]);
+ devcount = odevcount = ARRAY_SIZE(devices);
oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0]));
ok(ret > 0, "expected non-zero\n");
ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount);
devcount = odevcount;
- odevcount = sizeof(devices) / sizeof(devices[0]);
+ odevcount = ARRAY_SIZE(devices);
ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0]));
ok(ret == 0, "expected 0, got %d\n", ret);
ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount);
@@ -1567,7 +1566,7 @@ static void test_key_map(void)
"Scan code -> vKey = %x (not VK_RSHIFT)\n", kR);
/* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */
- for (i = 0; i < sizeof(numpad_collisions)/sizeof(numpad_collisions[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(numpad_collisions); i++)
{
UINT numpad_scan = MapVirtualKeyExA(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl);
UINT other_scan = MapVirtualKeyExA(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl);
@@ -1665,7 +1664,7 @@ static void test_ToUnicode(void)
"ToUnicode didn't null-terminate the buffer when there was room.\n");
}
- for (i = 0; i < sizeof(utests) / sizeof(utests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(utests); i++)
{
UINT vk = utests[i].vk, mod = utests[i].modifiers, scan;
@@ -1808,7 +1807,7 @@ static void test_key_names(void)
ok( buffer[0] == 0, "wrong string '%s'\n", buffer );
memset( bufferW, 0xcc, sizeof(bufferW) );
- ret = GetKeyNameTextW( lparam, bufferW, sizeof(bufferW)/sizeof(WCHAR) );
+ ret = GetKeyNameTextW( lparam, bufferW, ARRAY_SIZE(bufferW));
ok( ret > 0, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
ok( ret == lstrlenW(bufferW), "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index 88d3adb728..c6edc76ea2 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -51,7 +51,7 @@ static int strcmp_aw(LPCWSTR strw, const char *stra)
WCHAR buf[1024];
if (!stra) return 1;
- MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf);
}
diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index 0f6e8618a6..7f338ce9b1 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -668,7 +668,7 @@ static void test_menu_ownerdraw(void)
ok( ret, "AppendMenu failed for %d\n", k-1);
}
MOD_maxid = k-1;
- assert( k <= sizeof(MOD_rc)/sizeof(RECT));
+ assert( k <= ARRAY_SIZE(MOD_rc));
/* display the menu */
TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
@@ -986,14 +986,14 @@ static void test_menu_bmp_and_string(void)
for( ispop=1; ispop >= 0; ispop--){
static SIZE bmsizes[]= {
{10,10},{38,38},{1,30},{55,5}};
- for( szidx=0; szidx < sizeof( bmsizes) / sizeof( SIZE); szidx++) {
+ for( szidx=0; szidx < ARRAY_SIZE(bmsizes); szidx++) {
HBITMAP hbm = CreateBitmap( bmsizes[szidx].cx, bmsizes[szidx].cy,1,1,bmfill);
HBITMAP bitmaps[] = { HBMMENU_CALLBACK, hbm, HBMMENU_POPUP_CLOSE, NULL };
ok( hbm != 0, "CreateBitmap failed err %d\n", GetLastError());
- for( txtidx = 0; txtidx < sizeof(MOD_txtsizes)/sizeof(MOD_txtsizes[0]); txtidx++) {
+ for( txtidx = 0; txtidx < ARRAY_SIZE(MOD_txtsizes); txtidx++) {
for( hassub = 0; hassub < 2 ; hassub++) { /* add submenu item */
for( mnuopt = 0; mnuopt < 3 ; mnuopt++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */
- for( bmpidx = 0; bmpidx <sizeof(bitmaps)/sizeof(HBITMAP); bmpidx++) {
+ for( bmpidx = 0; bmpidx <ARRAY_SIZE(bitmaps); bmpidx++) {
/* no need to test NULL bitmaps of several sizes */
if( !bitmaps[bmpidx] && szidx > 0) continue;
/* the HBMMENU_POPUP not to test for menu bars */
@@ -2757,9 +2757,8 @@ static void test_menu_resource_layout(void)
ok(ret, "AppendMenu failed\n");
count = GetMenuItemCount(hmenu);
- ok(count == sizeof(menu_data)/sizeof(menu_data[0]),
- "expected %u menu items, got %u\n",
- (UINT)(sizeof(menu_data)/sizeof(menu_data[0])), count);
+ ok(count == ARRAY_SIZE(menu_data), "expected %u menu items, got %u\n",
+ (UINT) ARRAY_SIZE(menu_data), count);
for (i = 0; i < count; i++)
{
@@ -2978,9 +2977,9 @@ static void test_InsertMenu(void)
};
HMENU hmenu;
-#define create_menu(a) create_menu_from_data((a), sizeof(a)/sizeof((a)[0]))
-#define create_menuitem(a) create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0]))
-#define compare_menu(h, a) compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0]))
+#define create_menu(a) create_menu_from_data((a), ARRAY_SIZE(a))
+#define create_menuitem(a) create_menuitem_from_data((a), ARRAY_SIZE(a))
+#define compare_menu(h, a) compare_menu_data((h), (a), ARRAY_SIZE(a))
hmenu = create_menu(in1);
compare_menu(hmenu, out1);
diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c
index 4d7b020e14..f4c1a4b17c 100644
--- a/dlls/user32/tests/monitor.c
+++ b/dlls/user32/tests/monitor.c
@@ -398,7 +398,7 @@ static void test_monitors(void)
/* tests for cbSize in MONITORINFO */
monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
- for (i = 0; i < (sizeof(testdatami) / sizeof(testdatami[0])); i++)
+ for (i = 0; i < ARRAY_SIZE(testdatami); i++)
{
memset( &mi, 0, sizeof(mi) );
mi.cbSize = testdatami[i].cbSize;
@@ -420,7 +420,7 @@ static void test_monitors(void)
}
/* tests for cbSize in MONITORINFOEXA */
- for (i = 0; i < (sizeof(testdatamiexa) / sizeof(testdatamiexa[0])); i++)
+ for (i = 0; i < ARRAY_SIZE(testdatamiexa); i++)
{
memset( &miexa, 0, sizeof(miexa) );
miexa.cbSize = testdatamiexa[i].cbSize;
@@ -433,7 +433,7 @@ static void test_monitors(void)
}
/* tests for cbSize in MONITORINFOEXW */
- for (i = 0; i < (sizeof(testdatamiexw) / sizeof(testdatamiexw[0])); i++)
+ for (i = 0; i < ARRAY_SIZE(testdatamiexw); i++)
{
memset( &miexw, 0, sizeof(miexw) );
miexw.cbSize = testdatamiexw[i].cbSize;
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index a0f2cbeef0..1f2c0dd1f7 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -4966,7 +4966,7 @@ static void test_WM_DEVICECHANGE(HWND hwnd)
DBT_DEVICETYPESPECIFIC,
DBT_CUSTOMEVENT};
- for (i = 0; i < sizeof(wparams)/sizeof(wparams[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(wparams); i++)
{
SetLastError(0xdeadbeef);
ret = PostMessageA(hwnd, WM_DEVICECHANGE, wparams[i], 0);
@@ -6273,7 +6273,7 @@ static void test_button_messages(void)
hfont2 = CreateFontIndirectA(&logfont);
ok(hfont2 != NULL, "Failed to create Tahoma font\n");
- for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(button); i++)
{
MSG msg;
DWORD style, state;
@@ -6686,7 +6686,7 @@ static void test_static_messages(void)
subclass_static();
- for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(static_ctrl); i++)
{
hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
0, 0, 50, 14, 0, 0, 0, NULL);
@@ -9729,13 +9729,13 @@ static void test_timers_no_wnd(void)
win_skip("SetCoalescableTimer not available.\n");
/* Check what happens when we're running out of timers */
- for (i=0; i<sizeof(ids)/sizeof(ids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ids); i++)
{
SetLastError(0xdeadbeef);
ids[i] = SetTimer(NULL, 0, USER_TIMER_MAXIMUM, tfunc);
if (!ids[i]) break;
}
- ok(i != sizeof(ids)/sizeof(ids[0]), "all timers were created successfully\n");
+ ok(i != ARRAY_SIZE(ids), "all timers were created successfully\n");
ok(GetLastError()==ERROR_NO_MORE_USER_HANDLES || broken(GetLastError()==0xdeadbeef),
"GetLastError() = %d\n", GetLastError());
while (i > 0) KillTimer(NULL, ids[--i]);
@@ -10113,7 +10113,7 @@ static void test_winevents(void)
ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
}
- for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(WmWinEventsSeq); i++)
pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
@@ -12797,7 +12797,7 @@ static void test_ShowWindow(void)
ok(EqualRect(&win_rc, &wp.rcNormalPosition), "expected %s got %s\n", wine_dbgstr_rect(&win_rc),
wine_dbgstr_rect(&wp.rcNormalPosition));
- for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(sw); i++)
{
static const char * const sw_cmd_name[13] =
{
@@ -14660,20 +14660,20 @@ static void test_defwinproc(void)
flush_events();
buffA[0] = 0;
- GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA));
+ GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA));
ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA);
/* Zero high word of the lParam */
res = DefWindowProcA(hwnd, WM_SETTEXT, 0, 0x1234);
ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res);
- GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA));
+ GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA));
ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA);
res = DefWindowProcW(hwnd, WM_SETTEXT, 0, 0x1234);
ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res);
- GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA));
+ GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA));
ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA);
GetCursorPos(&pos);
@@ -14933,7 +14933,7 @@ static void test_PostMessage(void)
PostMessageA(hwnd, WM_USER+1, 0x1234, 0x5678);
PostMessageA(0, WM_USER+2, 0x5678, 0x1234);
- for (i = 0; i < sizeof(data)/sizeof(data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(data); i++)
{
memset(&msg, 0xab, sizeof(msg));
ret = PeekMessageA(&msg, data[i].hwnd, 0, 0, PM_NOREMOVE);
@@ -14991,7 +14991,7 @@ static void test_broadcast(void)
oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)broadcast_test_proc);
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
- for (i = 0; i < sizeof(messages)/sizeof(messages[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(messages); i++)
{
BOOL ret;
MSG msg;
@@ -15321,7 +15321,7 @@ static void test_WaitForInputIdle( char *argv0 )
thread = CreateThread( NULL, 0, wait_idle_thread, NULL, 0, &id );
- for (i = 0; i < sizeof(wait_idle_expect)/sizeof(wait_idle_expect[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(wait_idle_expect); i++)
{
ResetEvent( start_event );
ResetEvent( end_event );
diff --git a/dlls/user32/tests/resource.c b/dlls/user32/tests/resource.c
index 2388adb64f..5d4c4e2f96 100644
--- a/dlls/user32/tests/resource.c
+++ b/dlls/user32/tests/resource.c
@@ -50,7 +50,7 @@ static void test_LoadStringW(void)
win_skip( "LoadStringW does not return a pointer to the resource\n" );
return;
}
- length2 = LoadStringW(hInst, 2, returnedstringw, sizeof(returnedstringw) /sizeof(WCHAR)); /* get resource string */
+ length2 = LoadStringW(hInst, 2, returnedstringw, ARRAY_SIZE(returnedstringw)); /* get resource string */
ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d\n", length2, GetLastError());
ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n",
length1, length2);
@@ -93,7 +93,7 @@ static void test_LoadStringA (void)
int ret, ret2;
assert (sizeof str < sizeof buf);
- for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
const unsigned int bufsiz = tests[i].bufsiz;
const unsigned int expected = tests[i].expected;
const int len = LoadStringA (hInst, 0, buf, bufsiz);
diff --git a/dlls/user32/tests/scroll.c b/dlls/user32/tests/scroll.c
index 0bda5dd0f4..291d11af0f 100644
--- a/dlls/user32/tests/scroll.c
+++ b/dlls/user32/tests/scroll.c
@@ -514,7 +514,7 @@ static void scrollbar_test_init(void)
wc.lpfnWndProc = scroll_init_proc;
RegisterClassExA(&wc);
- for(i = 0; i < sizeof style / sizeof style[0]; i++)
+ for(i = 0; i < ARRAY_SIZE(style); i++)
{
/* need not to destroy these windows due creation abort */
CreateWindowExA(0, cls_name, NULL, style[i],
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c
index ce056e9160..3db058f950 100644
--- a/dlls/user32/tests/sysparams.c
+++ b/dlls/user32/tests/sysparams.c
@@ -710,7 +710,7 @@ static void test_SPI_SETMOUSE( void ) /* 4 */
POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
- int nchange = sizeof( req_change ) / sizeof( POINT );
+ int nchange = ARRAY_SIZE(req_change);
trace("testing SPI_{GET,SET}MOUSE\n");
SetLastError(0xdeadbeef);
@@ -875,7 +875,7 @@ static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDSPEED"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -964,7 +964,7 @@ static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVETIMEOUT"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -1001,7 +1001,7 @@ static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVEACTIVE"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -1042,7 +1042,7 @@ static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDDELAY"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT delay;
char buf[10];
@@ -1143,7 +1143,7 @@ static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
if (!test_error_msg(rc,"SPI_{GET,SET}ICONTITLEWRAP"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
UINT regval;
@@ -1187,7 +1187,7 @@ static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
if (!test_error_msg(rc,"SPI_{GET,SET}MENUDROPALIGNMENT"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -1223,7 +1223,7 @@ static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
old_width = GetSystemMetrics( SM_CXDOUBLECLK );
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
char buf[10];
@@ -1257,7 +1257,7 @@ static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
old_height = GetSystemMetrics( SM_CYDOUBLECLK );
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
char buf[10];
@@ -1347,7 +1347,7 @@ static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
old_b = GetSystemMetrics( SM_SWAPBUTTON );
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
SetLastError(0xdeadbeef);
rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
@@ -1402,7 +1402,7 @@ static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
if (!test_error_msg(rc,"SPI_{GET,SET}DRAGFULLWINDOWS"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -1925,7 +1925,7 @@ static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
if (!test_error_msg(rc,"SPI_{GET,SET}SHOWSOUNDS"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -1962,7 +1962,7 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDPREF"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
BOOL v;
@@ -1997,7 +1997,7 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */
if (!test_error_msg(rc,"SPI_{GET,SET}SCREENREADER"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
BOOL v;
@@ -2036,7 +2036,7 @@ static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */
SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &old_contrast, 0 );
SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &old_orient, 0 );
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -2113,7 +2113,7 @@ static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
if (!test_error_msg(rc,"SPI_{GET,SET}LOWPOWERACTIVE"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -2151,7 +2151,7 @@ static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
if (!test_error_msg(rc,"SPI_{GET,SET}POWEROFFACTIVE"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -2189,7 +2189,7 @@ static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */
if (!test_error_msg(rc,"SPI_GETSNAPTODEFBUTTON"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
@@ -2224,7 +2224,7 @@ static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERWIDTH"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -2261,7 +2261,7 @@ static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERHEIGHT"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -2302,7 +2302,7 @@ static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERTIME"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -2341,7 +2341,7 @@ static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLLINES"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -2380,7 +2380,7 @@ static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
if (!test_error_msg(rc,"SPI_{GET,SET}MENUSHOWDELAY"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -2419,7 +2419,7 @@ static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */
if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLCHARS"))
return;
- for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
+ for (i=0;i<ARRAY_SIZE(vals);i++)
{
UINT v;
char buf[10];
@@ -2489,7 +2489,7 @@ static void test_WM_DISPLAYCHANGE(void)
displaychange_sem = CreateSemaphoreW(NULL, 0, 1, NULL);
- for(i = 0; i < sizeof(test_bpps)/sizeof(test_bpps[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(test_bpps); i++) {
last_bpp = -1;
memset(&mode, 0, sizeof(mode));
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c
index c5bcd50716..359721fcd9 100644
--- a/dlls/user32/tests/text.c
+++ b/dlls/user32/tests/text.c
@@ -765,7 +765,7 @@ static void test_CharToOem_OemToChar(void)
char oem;
WCHAR uni, expect;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
const char *expected = tests[i].ret ? helloWorld : "";
const char *src = tests[i].src ? helloWorld : NULL;
@@ -792,7 +792,7 @@ static void test_CharToOem_OemToChar(void)
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
}
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
const char *expected = tests[i].ret ? helloWorld : "";
const WCHAR *src = tests[i].src ? helloWorldW : NULL;
@@ -804,12 +804,12 @@ static void test_CharToOem_OemToChar(void)
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
memset(buf, 0, sizeof(buf));
- ret = CharToOemBuffW(src, dst, sizeof(helloWorldW)/sizeof(WCHAR));
+ ret = CharToOemBuffW(src, dst, ARRAY_SIZE(helloWorldW));
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
}
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW;
const char *src = tests[i].src ? helloWorld : NULL;
diff --git a/dlls/user32/tests/uitools.c b/dlls/user32/tests/uitools.c
index b52fe3a03a..07cf776a95 100644
--- a/dlls/user32/tests/uitools.c
+++ b/dlls/user32/tests/uitools.c
@@ -175,7 +175,7 @@ static void test_IsRectEmpty(void)
{{-109, -107, -103, -101}, FALSE},
};
- for (i = 0; i < sizeof(rtest)/sizeof(rtest[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(rtest); i++) {
ret = IsRectEmpty(&rtest[i].rect);
ok(ret == rtest[i].ret, "Test %d: IsRectEmpty returned %s for %s\n", i,
ret ? "TRUE" : "FALSE", wine_dbgstr_rect(&rtest[i].rect));
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 1f10d66dcd..d7f8843c98 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -2158,7 +2158,7 @@ static void test_mdi(void)
client_cs.hWindowMenu = 0;
client_cs.idFirstChild = 1;
- for (i = 0; i < sizeof(style)/sizeof(style[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(style); i++)
{
SCROLLINFO si;
BOOL ret, gotit;
@@ -6390,7 +6390,7 @@ static void test_set_window_style(void)
cls.lpszClassName = "TestSetWindowStylesClass";
ok(RegisterClassA(&cls), "RegisterClass failed\n");
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
expected_style = tests[i].style;
if (tests[i].creation_style & WS_MINIMIZE)
@@ -6857,7 +6857,7 @@ static void test_gettext(void)
num_gettext_msgs = 0;
memset( bufW, 0xcc, sizeof(bufW) );
g_wm_gettext_override.buffW = bufW;
- buf_len = GetWindowTextW( hwnd2, bufW, sizeof(bufW)/sizeof(WCHAR) );
+ buf_len = GetWindowTextW( hwnd2, bufW, ARRAY_SIZE(bufW));
ok( buf_len == 0, "got %d\n", buf_len );
ok( *bufW == 0, "got %x\n", *bufW );
ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
@@ -6955,7 +6955,7 @@ static void test_gettext(void)
memset( bufW, 0x1c, sizeof(bufW) );
g_wm_gettext_override.dont_terminate = TRUE;
- buf_len = GetWindowTextW( hwnd, bufW, sizeof(bufW)/sizeof(bufW[0]) );
+ buf_len = GetWindowTextW( hwnd, bufW, ARRAY_SIZE(bufW));
ok( buf_len == 4, "Unexpected text length, %d\n", buf_len );
ok( !memcmp(bufW, textW, 4 * sizeof(WCHAR)), "Unexpected window text, %s\n", wine_dbgstr_w(bufW) );
ok( bufW[4] == 0, "Unexpected buffer contents, %#x\n", bufW[4] );
@@ -6974,7 +6974,7 @@ static void test_gettext(void)
memset( bufW, 0x1c, sizeof(bufW) );
g_wm_gettext_override.dont_terminate = TRUE;
- buf_len = GetWindowTextW( hwnd2, bufW, sizeof(bufW)/sizeof(bufW[0]) );
+ buf_len = GetWindowTextW( hwnd2, bufW, ARRAY_SIZE(bufW));
ok( buf_len == 4, "Unexpected text length, %d\n", buf_len );
ok( !memcmp(bufW, textW, 4 * sizeof(WCHAR)), "Unexpected window text, %s\n", wine_dbgstr_w(bufW) );
ok( bufW[4] == 0x1c1c, "Unexpected buffer contents, %#x\n", bufW[4] );
@@ -7399,7 +7399,7 @@ static void test_hwnd_message(void)
if (parent) ok( !IsWindowVisible( parent ), "HWND_MESSAGE parent is visible\n" );
/* GetWindowLong */
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
SetLastError( 0xdeadbeef );
result = GetWindowLongPtrW( parent, tests[i].offset );
@@ -7679,14 +7679,14 @@ static void test_fullscreen(void)
cls.lpszClassName = "fullscreen_class";
RegisterClassA(&cls);
- for (i = 0; i < sizeof(t_style)/sizeof(t_style[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(t_style); i++)
{
DWORD style, ex_style;
/* avoid a WM interaction */
assert(!(t_style[i] & WS_VISIBLE));
- for (j = 0; j < sizeof(t_ex_style)/sizeof(t_ex_style[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(t_ex_style); j++)
{
int fixup;
@@ -8430,7 +8430,7 @@ static void create_window_tree(HWND parent, HWND *window, int size)
memset(window, 0, size * sizeof(window[0]));
pos = 0;
- for (i = 0; i < sizeof(style)/sizeof(style[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(style); i++)
{
assert(pos < size);
window[pos] = CreateWindowExA(0, "my_window", NULL, style[i] | WS_CHILD,
@@ -8577,7 +8577,7 @@ static void test_child_window_from_point(void)
ok(parent != 0, "CreateWindowEx failed\n");
trace("parent %p\n", parent);
- create_window_tree(parent, window, sizeof(window)/sizeof(window[0]));
+ create_window_tree(parent, window, ARRAY_SIZE(window));
found_invisible = 0;
found_disabled = 0;
@@ -8586,14 +8586,14 @@ static void test_child_window_from_point(void)
found_extransparent = 0;
/* FIXME: also test WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx */
- for (i = 0; i < sizeof(real_child_pos)/sizeof(real_child_pos[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(real_child_pos); i++)
{
struct window_attributes attrs;
pt.x = pt.y = 50;
hwnd = RealChildWindowFromPoint(parent, pt);
ok(hwnd != 0, "RealChildWindowFromPoint failed\n");
- ret = window_to_index(hwnd, window, sizeof(window)/sizeof(window[0]));
+ ret = window_to_index(hwnd, window, ARRAY_SIZE(window));
/* FIXME: remove once Wine is fixed */
todo_wine_if (ret != real_child_pos[i])
ok(ret == real_child_pos[i], "expected %d, got %d\n", real_child_pos[i], ret);
@@ -9782,7 +9782,7 @@ static void test_LockWindowUpdate(HWND parent)
UpdateWindow(parent);
flush_events(TRUE);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
HDC hdc;
POINT p = {10, 10};
@@ -10047,7 +10047,7 @@ static void test_desktop( void )
DWORD_PTR result;
int i;
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
SetLastError( 0xdeadbeef );
result = GetWindowLongPtrW( desktop, tests[i].offset );
@@ -10143,7 +10143,7 @@ static void test_topmost(void)
ok(!is_topmost(hwnd), "hwnd %p topmost state is wrong\n", hwnd);
ok(!is_topmost(hwnd2), "hwnd %p topmost state is wrong\n", hwnd2);
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10183,7 +10183,7 @@ todo_wine
ok(!is_topmost(hwnd2), "hwnd %p topmost state is wrong\n", hwnd2);
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, 0, hwnd2, owner, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10197,7 +10197,7 @@ todo_wine
ok(!is_topmost(hwnd2), "hwnd %p topmost state is wrong\n", hwnd2);
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, 0, hwnd2, owner, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10218,7 +10218,7 @@ if (!is_wine) /* FIXME: remove once Wine is fixed */
ok(!is_topmost(hwnd2), "hwnd %p topmost state is wrong\n", hwnd2);
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, 0, hwnd2, owner, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
hwnd_child2 = create_tool_window(WS_VISIBLE|WS_POPUP, hwnd);
ok(hwnd_child2 != 0, "Failed to create popup window (%d)\n", GetLastError());
@@ -10268,7 +10268,7 @@ todo_wine
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10292,7 +10292,7 @@ todo_wine
ok(!is_topmost(hwnd_grandchild), "hwnd %p topmost state is wrong\n", hwnd_grandchild);
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10316,7 +10316,7 @@ todo_wine
ok(!is_topmost(hwnd_grandchild), "hwnd %p topmost state is wrong\n", hwnd_grandchild);
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd_child, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10350,7 +10350,7 @@ todo_wine
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd_child, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10373,7 +10373,7 @@ todo_wine
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd_grandchild, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10394,7 +10394,7 @@ if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd_child, 0, hwnd_child2, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd_child, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10418,7 +10418,7 @@ if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, 0, hwnd2, owner, FALSE);
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd_child, 0, hwnd_child2, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
swp_after(hwnd_child, HWND_TOPMOST);
ok(!is_topmost(owner), "hwnd %p topmost state is wrong\n", owner);
@@ -10442,7 +10442,7 @@ if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd, hwnd2, 0, owner, FALSE);
if (!is_wine) /* FIXME: remove once Wine is fixed */
check_z_order(hwnd_child, 0, hwnd_child2, hwnd, FALSE);
- reset_window_state(state, sizeof(state)/sizeof(state[0]));
+ reset_window_state(state, ARRAY_SIZE(state));
DestroyWindow(hwnd_grandchild);
DestroyWindow(hwnd_child);
diff --git a/dlls/user32/tests/wsprintf.c b/dlls/user32/tests/wsprintf.c
index f0e80b2ad6..f79b6306a7 100644
--- a/dlls/user32/tests/wsprintf.c
+++ b/dlls/user32/tests/wsprintf.c
@@ -66,7 +66,7 @@ static void wsprintfATest(void)
win_skip( "I64 formats not supported\n" );
return;
}
- for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(i64_formats); i++)
{
rc = wsprintfA(buf, i64_formats[i].fmt, i64_formats[i].value);
ok(rc == strlen(i64_formats[i].res), "%u: wsprintfA length failure: rc=%d\n", i, rc);
@@ -98,10 +98,10 @@ static void wsprintfWTest(void)
win_skip( "I64 formats not supported\n" );
return;
}
- for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(i64_formats); i++)
{
- MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, sizeof(fmt)/sizeof(WCHAR) );
- MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, sizeof(res)/sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, ARRAY_SIZE(fmt));
+ MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, ARRAY_SIZE(res));
rc = wsprintfW(buf, fmt, i64_formats[i].value);
ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc);
ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf));
--
2.14.4