Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2018
- 68 participants
- 1149 messages
Re: [PATCH 2/2] user32/tests: Skip tests for window messages if we failed to receive foreground status.
by Zebediah Figura
On 17/06/18 16:20, Marvin wrote:
> Hi,
>
> While running your changed tests on Windows, I think I found new failures.
> Being a bot and all I'm not very good at pattern recognition, so I might be
> wrong, but could you please double-check?
> Full results can be found at
> https://testbot.winehq.org/JobDetails.pl?Key=39204
>
> Your paranoid android.
>
>
> === w7pro64 (64 bit input) ===
> input.c:2055: Test failed: expected WM_NCHITTEST message
> input.c:2082: Test failed: expected loop with WM_NCHITTEST messages
> input.c:2135: Test failed: expected WM_LBUTTONDOWN message
> input.c:2136: Test failed: expected WM_LBUTTONUP message
>
>
This failure is in a different test, and should not be affected by my
changes. A similar failure can be seen here:
http://test.winehq.org/data/8e9ea7a8a163147012908bad696a539454654d8f/win7_n…
June 17, 2018
[PATCH] riched20/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/riched20/tests/editor.c | 62 ++++++++++++++++++++-----------------------
dlls/riched20/tests/richole.c | 4 +--
2 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 2a6907bfe7..85c607becf 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -340,14 +340,12 @@ static void test_EM_FINDTEXT(BOOL unicode)
hwndRichEdit = new_richedit(NULL);
/* Empty rich edit control */
- run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests,
- sizeof(find_tests)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, ARRAY_SIZE(find_tests), unicode);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack);
/* Haystack text */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, ARRAY_SIZE(find_tests2), unicode);
/* Setting a format on an arbitrary range should have no effect in search
results. This tests correct offset reporting across runs. */
@@ -359,8 +357,7 @@ static void test_EM_FINDTEXT(BOOL unicode)
SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
/* Haystack text, again */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2, ARRAY_SIZE(find_tests2), unicode);
/* Yet another range */
cf2.dwMask = CFM_BOLD | cf2.dwMask;
@@ -369,8 +366,7 @@ static void test_EM_FINDTEXT(BOOL unicode)
SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
/* Haystack text, again */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2, ARRAY_SIZE(find_tests2), unicode);
DestroyWindow(hwndRichEdit);
}
@@ -404,7 +400,7 @@ static void test_EM_GETLINE(void)
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text);
memset(origdest, 0xBB, nBuf);
- for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++)
+ for (i = 0; i < ARRAY_SIZE(gl); i++)
{
int nCopied;
int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text));
@@ -509,7 +505,7 @@ static void test_EM_LINELENGTH(void)
{15, 4}, /* Line 3: |wine */
};
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
- for (i = 0; i < sizeof(offset_test1)/sizeof(offset_test1[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(offset_test1); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0);
ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n",
offset_test1[i][0], result, offset_test1[i][1]);
@@ -2049,7 +2045,7 @@ static void test_EM_AUTOURLDETECT(void)
urlRet=SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, (WPARAM)"h", (LPARAM)"h");
ok(urlRet==E_INVALIDARG, "Bad wParam2: urlRet is: %d\n", urlRet);
/* for each url, check the text to see if CFE_LINK effect is present */
- for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) {
+ for (i = 0; i < ARRAY_SIZE(urls); i++) {
SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, FALSE, 0);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)urls[i].text);
@@ -2063,10 +2059,10 @@ static void test_EM_AUTOURLDETECT(void)
DestroyWindow(hwndRichEdit);
/* Test detection of URLs within normal text - WM_SETTEXT case. */
- for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) {
+ for (i = 0; i < ARRAY_SIZE(urls); i++) {
hwndRichEdit = new_richedit(parent);
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2117,7 +2113,7 @@ static void test_EM_AUTOURLDETECT(void)
}
}
- for (j = 0; j < sizeof(templates_non_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_non_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2158,7 +2154,7 @@ static void test_EM_AUTOURLDETECT(void)
}
}
- for (j = 0; j < sizeof(templates_xten_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_xten_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2213,7 +2209,7 @@ static void test_EM_AUTOURLDETECT(void)
}
}
- for (j = 0; j < sizeof(templates_neutral_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_neutral_delim); j++) {
char * at_pos, * end_pos;
int at_offset;
int end_offset;
@@ -2421,7 +2417,7 @@ static void test_EM_AUTOURLDETECT(void)
*/
/* Set entire text in one go, like WM_SETTEXT */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2476,7 +2472,7 @@ static void test_EM_AUTOURLDETECT(void)
}
/* Set selection with X to the URL */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2530,7 +2526,7 @@ static void test_EM_AUTOURLDETECT(void)
}
/* Set selection with X to the first character of the URL, then the rest */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2598,7 +2594,7 @@ static void test_EM_AUTOURLDETECT(void)
hwndRichEdit = new_richedit(parent);
/* Set selection with X to the URL */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2649,7 +2645,7 @@ static void test_EM_AUTOURLDETECT(void)
}
/* Set selection with X to the first character of the URL, then the rest */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -4933,7 +4929,7 @@ static void test_EM_EXSETSEL(void)
{
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
@@ -4988,7 +4984,7 @@ static void test_EM_SETSEL(void)
char buffA[32] = {0};
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
@@ -5623,7 +5619,7 @@ static void test_EM_FORMATRANGE(void)
SendMessageA(hwndRichEdit, EM_FORMATRANGE, FALSE, 0);
- for (i = 0; i < sizeof(fmtstrings)/sizeof(fmtstrings[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(fmtstrings); i++)
{
GETTEXTLENGTHEX gtl;
SIZE stringsize;
@@ -5831,7 +5827,7 @@ static void test_EM_STREAMIN(void)
};
const WCHAR streamText5[] = { 'T', 'e', 's', 't', 'S', 'o', 'm', 'e', 'T', 'e', 'x', 't' };
- int length5 = sizeof(streamText5) / sizeof(WCHAR);
+ int length5 = ARRAY_SIZE(streamText5);
struct StringWithLength cookieForStream5 = {
sizeof(streamText5),
(char *)streamText5,
@@ -6868,7 +6864,7 @@ static void test_EN_LINK(void)
GetCursorPos(&orig_cursor_pos);
SetCursorPos(0, 0);
- for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++)
{
link_notify_test("cursor position simulated", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
@@ -6878,7 +6874,7 @@ static void test_EN_LINK(void)
ClientToScreen(hwnd, &cursor_screen_pos);
SetCursorPos(cursor_screen_pos.x, cursor_screen_pos.y);
- for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++)
{
link_notify_test("cursor position set", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
@@ -8178,7 +8174,7 @@ static void test_EM_FINDWORDBREAK_W(void)
int i;
HWND hwndRichEdit = new_richeditW(NULL);
ok(IsWindowUnicode(hwndRichEdit), "window should be unicode\n");
- for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++)
{
WCHAR wbuf[2];
int result;
@@ -8212,7 +8208,7 @@ static void test_EM_FINDWORDBREAK_A(void)
HWND hwndRichEdit = new_richedit(NULL);
ok(!IsWindowUnicode(hwndRichEdit), "window should not be unicode\n");
- for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++)
{
int result;
char buf[2];
@@ -8256,7 +8252,7 @@ static void test_enter(void)
HWND hwndRichEdit = new_richedit(NULL);
UINT i,j;
- for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
char buf[1024] = {0};
LRESULT result;
@@ -8538,7 +8534,7 @@ static void test_alignment_style(void)
EDITSTREAM es;
int i;
- for (i = 0; i < sizeof(align_style) / sizeof(align_style[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(align_style); i++)
{
DWORD dwStyle, new_align;
@@ -8646,8 +8642,8 @@ static void test_rtf(void)
result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es );
ok( result == 11, "got %ld\n", result );
- result = SendMessageW( edit, WM_GETTEXT, sizeof(buf)/sizeof(buf[0]), (LPARAM)buf );
- ok( result == sizeof(expect_specials)/sizeof(expect_specials[0]), "got %ld\n", result );
+ result = SendMessageW( edit, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf );
+ ok( result == ARRAY_SIZE(expect_specials), "got %ld\n", result );
ok( !memcmp( buf, expect_specials, sizeof(expect_specials) ), "got %s\n", wine_dbgstr_w(buf) );
/* Show that \rtlpar propagates to the second paragraph and is
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index c4fe425dfa..aaf52bcfdd 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -247,8 +247,8 @@ static void test_ITextDocument_Open(void)
tomReadOnly|tomShareDenyWrite, tomReadOnly|tomShareDenyRead
};
- int tomNumSingle = sizeof(tomConstantsSingle)/sizeof(tomConstantsSingle[0]);
- int tomNumMulti = sizeof(tomConstantsMulti)/sizeof(tomConstantsMulti[0]);
+ int tomNumSingle = ARRAY_SIZE(tomConstantsSingle);
+ int tomNumMulti = ARRAY_SIZE(tomConstantsMulti);
int i;
V_VT(&testfile) = VT_BSTR;
--
2.14.4
June 17, 2018
[PATCH] riched32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/riched32/tests/editor.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 6fe4005599..7751d2b402 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -104,7 +104,7 @@ static void test_WM_SETTEXT(void)
* for line breaking (only \n adds a line break)
*/
- for (i = 0; i < sizeof(testitems)/sizeof(testitems[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(testitems); i++) {
char buf[1024] = {0};
LRESULT result;
@@ -410,7 +410,7 @@ static void test_EM_GETLINE(void)
}
memset(origdest, 0xBB, nBuf);
- for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++)
+ for (i = 0; i < ARRAY_SIZE(gl); i++)
{
int nCopied, expected_nCopied, expected_bytes_written;
char gl_text[1024];
@@ -504,7 +504,7 @@ static void test_EM_LINELENGTH(void)
}
ok(result == 9, "Incorrect line count of %ld\n", result);
- for (i = 0; i < sizeof(offset_test)/sizeof(offset_test[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(offset_test); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test[i][0], 0);
ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
offset_test[i][0], result, offset_test[i][1]);
@@ -525,7 +525,7 @@ static void test_EM_LINELENGTH(void)
{16, 4}, /* Line 3: |wine */
};
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
- for (i = 0; i < sizeof(offset_test1)/sizeof(offset_test1[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(offset_test1); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0);
todo_wine_if (offset_test1[i][2])
ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n",
@@ -781,20 +781,17 @@ static void test_EM_FINDTEXT(void)
HWND hwndRichEdit = new_richedit(NULL);
/* Empty rich edit control */
- run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests,
- sizeof(find_tests)/sizeof(struct find_s));
+ run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, ARRAY_SIZE(find_tests));
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack);
/* Haystack text */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s));
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, ARRAY_SIZE(find_tests2));
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack2);
/* Haystack text 2 (with EOL characters) */
- run_tests_EM_FINDTEXT(hwndRichEdit, "3", find_tests3,
- sizeof(find_tests3)/sizeof(struct find_s));
+ run_tests_EM_FINDTEXT(hwndRichEdit, "3", find_tests3, ARRAY_SIZE(find_tests3));
DestroyWindow(hwndRichEdit);
}
@@ -1178,7 +1175,7 @@ static void test_enter(void)
HWND hwndRichEdit = new_richedit(NULL);
UINT i,j;
- for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
char buf[1024] = {0};
LRESULT result;
@@ -1321,7 +1318,7 @@ static void test_EM_EXSETSEL(void)
{
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
@@ -1378,7 +1375,7 @@ static void test_EM_SETSEL(void)
char buffA[32] = {0};
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
--
2.14.4
June 17, 2018
[PATCH 3/3] oleaut32/tests: Use a better type to avoid a cast
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/tests/safearray.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index dc23f58a40..bb4ed78185 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -765,7 +765,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
{
SAFEARRAY *sa;
HRESULT hres;
- int i;
+ UINT i;
/* Failure cases */
hres = SafeArrayAllocDescriptor(0, &sa);
@@ -789,7 +789,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
if (hres == S_OK)
{
- ok(SafeArrayGetDim(sa) == (UINT)i, "Dimension is %d; should be %d\n",
+ ok(SafeArrayGetDim(sa) == i, "Dimension is %d; should be %d\n",
SafeArrayGetDim(sa), i);
hres = SafeArrayDestroyDescriptor(sa);
--
2.14.4
June 17, 2018
[PATCH 2/3] oleaut32/tests: Avoid an ARRAY_SIZE-like macro
by Michael Stefaniuc
Also use a better type for the dimension variable.
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/tests/safearray.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index 8a215df04c..dc23f58a40 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -828,11 +828,9 @@ static void test_SafeArrayCreateLockDestroy(void)
SAFEARRAY *sa;
HRESULT hres;
VARTYPE vt;
- int dimension;
-
-#define NUM_DIMENSIONS (int)(sizeof(sab) / sizeof(sab[0]))
+ UINT dimension;
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = 0;
sab[dimension].cElements = 8;
@@ -850,7 +848,7 @@ static void test_SafeArrayCreateLockDestroy(void)
/* Don't test 0 sized dimensions, as Windows has a bug which allows this */
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
sab[dimension].cElements = 8;
/* Test all VARTYPES in 1-4 dimensions */
@@ -870,7 +868,7 @@ static void test_SafeArrayCreateLockDestroy(void)
if (sa)
{
- ok(SafeArrayGetDim(sa) == (UINT)dimension,
+ ok(SafeArrayGetDim(sa) == dimension,
"VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n",
vt, dimension, SafeArrayGetDim(sa), dimension);
ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8,
@@ -1007,13 +1005,13 @@ static void test_LockUnlock(void)
hres = SafeArrayUnlock(NULL);
ok(hres == E_INVALIDARG, "Lock NULL array hres 0x%x\n", hres);
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = 0;
sab[dimension].cElements = 8;
}
- sa = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab);
+ sa = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
/* Test maximum locks */
test_LockUnlock_Vector:
@@ -1054,27 +1052,27 @@ test_LockUnlock_Vector:
static void test_SafeArrayGetPutElement(void)
{
SAFEARRAYBOUND sab[4];
- LONG indices[NUM_DIMENSIONS], index;
+ LONG indices[ARRAY_SIZE(sab)], index;
SAFEARRAY *sa;
HRESULT hres;
int value = 0, gotvalue, dimension;
IRecordInfoImpl *irec;
unsigned int x,y,z,a;
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = dimension * 2 + 1;
sab[dimension].cElements = dimension * 3 + 1;
}
- sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
if (!sa)
return; /* Some early versions can't handle > 3 dims */
ok(sa->cbElements == sizeof(value), "int size mismatch\n");
/* Failure cases */
- for (x = 0; x < NUM_DIMENSIONS; x++)
+ for (x = 0; x < ARRAY_SIZE(sab); x++)
{
indices[0] = sab[0].lLbound;
indices[1] = sab[1].lLbound;
@@ -1384,16 +1382,16 @@ static void test_SafeArrayCopyData(void)
return;
}
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = dimension * 2 + 2;
sab[dimension].cElements = dimension * 3 + 1;
size *= sab[dimension].cElements;
}
- sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
ok(sa != NULL, "Copy test couldn't create array\n");
- sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
if (!sa || !sacopy)
@@ -1453,7 +1451,7 @@ static void test_SafeArrayCopyData(void)
hres = SafeArrayDestroy(sacopy);
ok(hres == S_OK, "got 0x%08x\n", hres);
- sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
@@ -1491,7 +1489,7 @@ static void test_SafeArrayCopyData(void)
"got 0x%04x\n", sacopy->fFeatures);
SafeArrayDestroy(sacopy);
- sacopy = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab);
+ sacopy = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
hres = SafeArrayCopyData(sa, sacopy);
@@ -1507,7 +1505,7 @@ static void test_SafeArrayCreateEx(void)
SAFEARRAYBOUND sab[4];
SAFEARRAY *sa;
HRESULT hres;
- int dimension;
+ UINT dimension;
if (!pSafeArrayCreateEx)
{
@@ -1515,7 +1513,7 @@ static void test_SafeArrayCreateEx(void)
return;
}
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = 0;
sab[dimension].cElements = 8;
--
2.14.4
June 17, 2018
[PATCH 1/3] oleaut32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/tests/olefont.c | 2 +-
dlls/oleaut32/tests/olepicture.c | 8 +++---
dlls/oleaut32/tests/safearray.c | 8 +++---
dlls/oleaut32/tests/tmarshal.c | 2 +-
dlls/oleaut32/tests/typelib.c | 26 ++++++++---------
dlls/oleaut32/tests/usrmarshal.c | 4 +--
dlls/oleaut32/tests/varformat.c | 16 +++++------
dlls/oleaut32/tests/vartest.c | 62 ++++++++++++++++++++--------------------
dlls/oleaut32/tests/vartype.c | 24 +++++++---------
9 files changed, 75 insertions(+), 77 deletions(-)
diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c
index f9c5625701..10e2a4cf2f 100644
--- a/dlls/oleaut32/tests/olefont.c
+++ b/dlls/oleaut32/tests/olefont.c
@@ -420,7 +420,7 @@ static void test_font_events_disp(void)
hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp);
EXPECT_HR(hr, S_OK);
- for (i = 0; i < sizeof(font_dispids)/sizeof(font_dispids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(font_dispids); i++)
{
switch (font_dispids[i].dispid)
{
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 7db1d844ba..50ba7652d8 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -501,7 +501,7 @@ static void test_Invoke(void)
/* DISPID_PICT_RENDER */
hdc = create_render_dc();
- for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(args); i++)
V_VT(&args[i]) = VT_I4;
V_I4(&args[0]) = 0;
@@ -679,7 +679,7 @@ static HRESULT picture_render(IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx,
IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
/* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */
- for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(args); i++)
V_VT(&args[i]) = VT_I4;
/* pack arguments and call */
@@ -884,7 +884,7 @@ static void test_OleLoadPicturePath(void)
{emptyW, &IID_IPicture, NULL},
};
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
pic = (IPicture *)0xdeadbeef;
hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0,
@@ -924,7 +924,7 @@ static void test_OleLoadPicturePath(void)
WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
CloseHandle(file);
- MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, sizeof(temp_fileW)/sizeof(WCHAR) - 8);
+ MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, ARRAY_SIZE(temp_fileW) - 8);
/* Try a normal DOS path. */
hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index 5ff29b3c3e..8a215df04c 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -567,7 +567,7 @@ static void test_safearray(void)
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD failed with hres %x\n", hres);
- for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
+ for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
if ((i == VT_I8 || i == VT_UI8) && has_i8)
{
vttypes[i].elemsize = sizeof(LONG64);
@@ -704,7 +704,7 @@ static void test_safearray(void)
if (!pSafeArrayAllocDescriptorEx)
return;
- for (i = 0; i < sizeof(vttypes)/sizeof(vttypes[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
a = NULL;
hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres);
@@ -1457,7 +1457,7 @@ static void test_SafeArrayCopyData(void)
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
- for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++)
+ for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++)
{
USHORT feature = ignored_copy_features[i];
USHORT orig = sacopy->fFeatures;
@@ -1765,7 +1765,7 @@ static void test_SafeArrayCopy(void)
ok(sa->fFeatures == 0, "got src features 0x%04x\n", sa->fFeatures);
sa->cbElements = 16;
- for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++)
+ for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++)
{
USHORT feature = ignored_copy_features[i];
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c
index 00cb4646c5..b48b7855db 100644
--- a/dlls/oleaut32/tests/tmarshal.c
+++ b/dlls/oleaut32/tests/tmarshal.c
@@ -725,7 +725,7 @@ static HRESULT WINAPI Widget_VarArg(
static BOOL mystruct_uint_ordered(MYSTRUCT *mystruct)
{
int i;
- for (i = 0; i < sizeof(mystruct->uarr)/sizeof(mystruct->uarr[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(mystruct->uarr); i++)
if (mystruct->uarr[i] != i)
return FALSE;
return TRUE;
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
index 4d5314e1ab..03031743df 100644
--- a/dlls/oleaut32/tests/typelib.c
+++ b/dlls/oleaut32/tests/typelib.c
@@ -627,7 +627,7 @@ static void test_CreateDispTypeInfo(void)
OLECHAR *name = func1;
ifdata.pmethdata = methdata;
- ifdata.cMembers = sizeof(methdata) / sizeof(methdata[0]);
+ ifdata.cMembers = ARRAY_SIZE(methdata);
methdata[0].szName = SysAllocString(func1);
methdata[0].ppdata = parms1;
@@ -1350,7 +1350,7 @@ static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
@@ -1483,7 +1483,7 @@ static void test_QueryPathOfRegTypeLib(DWORD arch)
if (!do_typelib_reg_key(&uid, 5, 37, arch, base, FALSE)) return;
if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, FALSE)) return;
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
@@ -2309,7 +2309,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(V_BSTR(¶mdescex.varDefaultValue));
WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
- MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, sizeof(nameW)/sizeof(nameW[0]));
+ MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
ok(hres == S_OK, "got %08x\n", hres);
@@ -3041,7 +3041,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 0, "got: %u\n", cnames);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -3145,7 +3145,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 3, "got: %u\n", cnames);
ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -3375,7 +3375,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -3474,7 +3474,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -4701,7 +4701,7 @@ static void test_dump_typelib(const char *name)
{
WCHAR wszName[MAX_PATH];
ITypeLib *typelib;
- int ticount = sizeof(info)/sizeof(info[0]);
+ int ticount = ARRAY_SIZE(info);
int iface, func;
MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH);
@@ -4739,7 +4739,7 @@ static void test_dump_typelib(const char *name)
HRESULT hr;
GUID guid;
- MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, sizeof(guidW)/sizeof(guidW[0]));
+ MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, ARRAY_SIZE(guidW));
IIDFromString(guidW, &guid);
expect_guid(&guid, &typeattr->guid);
@@ -5002,7 +5002,7 @@ static void test_register_typelib(BOOL system_registration)
}
- StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
+ StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
@@ -5050,7 +5050,7 @@ static void test_register_typelib(BOOL system_registration)
if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
attr->typekind == TKIND_DISPATCH)
{
- StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
+ StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
@@ -6204,7 +6204,7 @@ static void test_stub(void)
WCHAR guidW[40];
REGSAM opposite = side ^ (KEY_WOW64_64KEY | KEY_WOW64_32KEY);
- StringFromGUID2(&interfaceguid, guidW, sizeof(guidW)/sizeof(guidW[0]));
+ StringFromGUID2(&interfaceguid, guidW, ARRAY_SIZE(guidW));
/* Delete the opposite interface key */
lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey);
diff --git a/dlls/oleaut32/tests/usrmarshal.c b/dlls/oleaut32/tests/usrmarshal.c
index b9478d1b69..5ea13e418b 100644
--- a/dlls/oleaut32/tests/usrmarshal.c
+++ b/dlls/oleaut32/tests/usrmarshal.c
@@ -416,7 +416,7 @@ static void test_marshal_LPSAFEARRAY(void)
/* Test an array of VT_BSTR */
sab[0].lLbound = 3;
- sab[0].cElements = sizeof(values) / sizeof(values[0]);
+ sab[0].cElements = ARRAY_SIZE(values);
lpsa = SafeArrayCreate(VT_BSTR, 1, sab);
expected_bstr_size = 0;
@@ -463,7 +463,7 @@ static void test_marshal_LPSAFEARRAY(void)
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal, result %p\n", next);
- for (i = 0; i < sizeof(values) / sizeof(values[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(values); i++)
{
BSTR gotvalue = NULL;
diff --git a/dlls/oleaut32/tests/varformat.c b/dlls/oleaut32/tests/varformat.c
index 69476aa5d3..d713894870 100644
--- a/dlls/oleaut32/tests/varformat.c
+++ b/dlls/oleaut32/tests/varformat.c
@@ -80,7 +80,7 @@ static void test_VarFormatNumber(void)
CHECKPTR(VarFormatNumber);
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[0] != '.' || buff[1])
{
skip("Skipping VarFormatNumber tests as decimal separator is '%s'\n", buff);
@@ -127,7 +127,7 @@ static const char *szVarFmtFail = "VT %d|0x%04x Format %s: expected 0x%08x, '%s'
#define VARFMT(vt,v,val,fmt,ret,str) do { \
out = NULL; \
V_VT(&in) = (vt); v(&in) = val; \
- if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, sizeof(buffW)/sizeof(WCHAR)); \
+ if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, ARRAY_SIZE(buffW)); \
hres = pVarFormat(&in,fmt ? buffW : NULL,fd,fw,flags,&out); \
if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \
else buff[0] = '\0'; \
@@ -224,7 +224,7 @@ static const FMTDATERES VarFormat_namedtime_results[] =
};
#define VNUMFMT(vt,v) \
- for (i = 0; i < sizeof(VarFormat_results)/sizeof(FMTRES); i++) \
+ for (i = 0; i < ARRAY_SIZE(VarFormat_results); i++) \
{ \
VARFMT(vt,v,1,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].one_res); \
VARFMT(vt,v,0,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].zero_res); \
@@ -256,13 +256,13 @@ static void test_VarFormat(void)
skip("Skipping VarFormat tests for non English language\n");
return;
}
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[0] != '.' || buff[1])
{
skip("Skipping VarFormat tests as decimal separator is '%s'\n", buff);
return;
}
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, ARRAY_SIZE(buff));
if (buff[0] != '2' || buff[1])
{
skip("Skipping VarFormat tests as decimal places is '%s'\n", buff);
@@ -296,7 +296,7 @@ static void test_VarFormat(void)
VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bFalse,"True/False",S_OK,"False");
/* Dates */
- for (i = 0; i < sizeof(VarFormat_date_results)/sizeof(FMTDATERES); i++)
+ for (i = 0; i < ARRAY_SIZE(VarFormat_date_results); i++)
{
if (i < 7)
fd = i + 1; /* Test first day */
@@ -308,14 +308,14 @@ static void test_VarFormat(void)
}
/* Named time formats */
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, ARRAY_SIZE(buff));
if (strcmp(buff, "h:mm:ss tt"))
{
skip("Skipping named time tests as time format is '%s'\n", buff);
}
else
{
- for (i = 0; i < sizeof(VarFormat_namedtime_results)/sizeof(FMTDATERES); i++)
+ for (i = 0; i < ARRAY_SIZE(VarFormat_namedtime_results); i++)
{
fd = 0;
VARFMT(VT_DATE,V_DATE,VarFormat_namedtime_results[i].val,
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c
index 429ffbbb2e..c00968e225 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -537,7 +537,7 @@ static const char *vtstr(int x)
return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
default:
- vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
+ vtstr_current %= ARRAY_SIZE(vtstr_buffer);
sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x);
return vtstr_buffer[vtstr_current++];
}
@@ -545,7 +545,7 @@ static const char *vtstr(int x)
static const char *variantstr( const VARIANT *var )
{
- vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
+ vtstr_current %= ARRAY_SIZE(vtstr_buffer);
switch(V_VT(var))
{
case VT_I1:
@@ -664,7 +664,7 @@ static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT
static int strcmp_wa(const WCHAR *strw, const char *stra)
{
WCHAR buf[512];
- MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(buf[0]));
+ MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf);
}
@@ -792,7 +792,7 @@ static void test_VariantClear(void)
* Also demonstrates that null pointers in 'v' are not dereferenced.
* Individual variant tests should test VariantClear() with non-NULL values.
*/
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -921,7 +921,7 @@ static void test_VariantCopy(void)
*/
/* vSrc == vDst */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -949,7 +949,7 @@ static void test_VariantCopy(void)
memset(&vSrc, 0, sizeof(vSrc));
V_VT(&vSrc) = VT_UI1;
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -975,7 +975,7 @@ static void test_VariantCopy(void)
}
/* Test that VariantClear() checks vSrc for validity before copying */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -1079,7 +1079,7 @@ static void test_VariantCopyInd(void)
memset(buffer, 0, sizeof(buffer));
/* vSrc == vDst */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
if (ExtraFlags[i] & VT_ARRAY)
continue; /* Native crashes on NULL safearray */
@@ -1130,7 +1130,7 @@ static void test_VariantCopyInd(void)
V_VT(&vSrc) = VT_UI1|VT_BYREF;
V_BYREF(&vSrc) = &buffer;
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -1156,7 +1156,7 @@ static void test_VariantCopyInd(void)
}
/* bad src */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
if (ExtraFlags[i] & VT_ARRAY)
continue; /* Native crashes on NULL safearray */
@@ -1276,7 +1276,7 @@ static HRESULT convert_str( const char *str, INT dig, ULONG flags,
NUMPARSE *np, BYTE rgb[128], LCID lcid )
{
OLECHAR buff[128];
- MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP,0, str, -1, buff, ARRAY_SIZE( buff ));
memset( rgb, FAILDIG, 128 );
memset( np, 255, sizeof(*np) );
np->cDig = dig;
@@ -2291,7 +2291,7 @@ static void test_VarAbs(void)
/* Test all possible V_VT values.
*/
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -2354,7 +2354,7 @@ static void test_VarAbs(void)
hres = pVarAbs(&v,&vDst);
ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
"VarAbs(CY): expected 0x0 got 0x%X\n", hres);
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[1])
{
trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
@@ -2392,7 +2392,7 @@ static void test_VarNot(void)
CHECKPTR(VarNot);
/* Test all possible V_VT values */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -2523,7 +2523,7 @@ static void test_VarSub(void)
VariantInit(&result);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -3254,7 +3254,7 @@ static void test_VarFix(void)
CHECKPTR(VarFix);
/* Test all possible V_VT values */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -3369,7 +3369,7 @@ static void test_VarInt(void)
CHECKPTR(VarInt);
/* Test all possible V_VT values */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -3490,7 +3490,7 @@ static void test_VarNeg(void)
* native version. This at least ensures (as with all tests here) that
* we will notice if/when new vtypes/flags are added in native.
*/
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -3677,7 +3677,7 @@ static void test_VarRound(void)
VARROUND(DATE,-1.449,1,DATE,-1.4);
/* replace the decimal separator */
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (!buff[1]) {
szNumMin[2] = buff[0];
szNum[1] = buff[0];
@@ -3721,7 +3721,7 @@ static void test_VarRound(void)
"VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
/* VT_DECIMAL */
- for (i = 0; i < sizeof(decimal_round_data)/sizeof(struct decimal_round_t); i++)
+ for (i = 0; i < ARRAY_SIZE(decimal_round_data); i++)
{
const struct decimal_round_t *ptr = &decimal_round_data[i];
DECIMAL *pdec;
@@ -3786,7 +3786,7 @@ static void test_VarXor(void)
CHECKPTR(VarXor);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -4520,7 +4520,7 @@ static void test_VarOr(void)
CHECKPTR(VarOr);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -5252,7 +5252,7 @@ static void test_VarEqv(void)
CHECKPTR(VarEqv);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -5396,7 +5396,7 @@ static void test_VarMul(void)
rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -5567,7 +5567,7 @@ static void test_VarAdd(void)
rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -6231,7 +6231,7 @@ static void test_VarAnd(void)
false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -6947,7 +6947,7 @@ static void test_VarCmp(void)
bstr1few = SysAllocString(sz1few);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt;
@@ -7183,7 +7183,7 @@ static void test_VarPow(void)
num3_str = SysAllocString(str3);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -7709,7 +7709,7 @@ static void test_VarDiv(void)
num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -8082,7 +8082,7 @@ static void test_VarIdiv(void)
num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -8648,7 +8648,7 @@ static void test_VarImp(void)
false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index 9be2eb2901..e93a6e6a8d 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -112,7 +112,7 @@ static BOOL has_locales;
#define CONVERT_STR(func,str,flags) \
SetLastError(0); \
- if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
+ if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \
hres = func(str ? buff : NULL,in,flags,&out)
#define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \
@@ -2944,7 +2944,7 @@ static void test_VarDateFromDec(void)
#define DFS(str) \
buff[0] = '\0'; out = 0.0; \
- if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
+ if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \
hres = VarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
#define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \
@@ -3091,7 +3091,7 @@ static void test_VarDateFromStr(void)
DFS("1.2.3 4 5 6"); EXPECT_DBL(38812.04309027778);
DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334);
- for (i = 0; i < sizeof(BadDateStrings)/sizeof(char*); i++)
+ for (i = 0; i < ARRAY_SIZE(BadDateStrings); i++)
{
DFS(BadDateStrings[i]); EXPECT_MISMATCH;
}
@@ -4816,12 +4816,12 @@ static void test_VarBstrCmp(void)
/* These two strings are considered equal even though one is
* NULL-terminated and the other not.
*/
- bstr2 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR));
+ bstr2 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
VARBSTRCMP(bstr,bstr2,0,VARCMP_EQ);
SysFreeString(bstr2);
/* These two strings are not equal */
- bstr2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR));
+ bstr2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
VARBSTRCMP(bstr,bstr2,0,VARCMP_LT);
SysFreeString(bstr2);
@@ -5235,8 +5235,7 @@ if (0)
ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n");
- ok(SysStringLen(res) == sizeof(sz1sz2) / sizeof(WCHAR) - 1,
- "Unexpected length\n");
+ ok(SysStringLen(res) == ARRAY_SIZE(sz1sz2) - 1, "Unexpected length\n");
ok(!memcmp(res, sz1sz2, sizeof(sz1sz2)), "Unexpected value\n");
SysFreeString(res);
@@ -5244,14 +5243,13 @@ if (0)
SysFreeString(str1);
/* Concatenation of two strings with embedded NULLs */
- str1 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR));
- str2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR));
+ str1 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
+ str2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n");
- ok(SysStringLen(res) == sizeof(s1s2) / sizeof(WCHAR),
- "Unexpected length\n");
+ ok(SysStringLen(res) == ARRAY_SIZE(s1s2), "Unexpected length\n");
ok(!memcmp(res, s1s2, sizeof(s1s2)), "Unexpected value\n");
SysFreeString(res);
@@ -5893,13 +5891,13 @@ static void test_bstr_cache(void)
/* Fill the bucket with cached entries.
We roll our own, to show that the cache doesn't use
the bstr length field to determine bucket allocation. */
- for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
+ for(i=0; i < ARRAY_SIZE(strs); i++)
{
DWORD_PTR *ptr = CoTaskMemAlloc(64);
ptr[0] = 0;
strs[i] = (BSTR)(ptr + 1);
}
- for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
+ for(i=0; i < ARRAY_SIZE(strs); i++)
SysFreeString(strs[i]);
/* Following allocation will be made from cache */
--
2.14.4
June 17, 2018
[PATCH] winedbg: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/winedbg/crashdlg.c | 13 ++++++-------
programs/winedbg/gdbproxy.c | 12 ++++++------
programs/winedbg/tgt_active.c | 6 +++---
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/programs/winedbg/crashdlg.c b/programs/winedbg/crashdlg.c
index 4e02a4bb7c..5c913ff7a1 100644
--- a/programs/winedbg/crashdlg.c
+++ b/programs/winedbg/crashdlg.c
@@ -38,8 +38,8 @@ int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UINT uType)
{
WCHAR caption[256];
WCHAR text[256];
- LoadStringW(GetModuleHandleW(NULL), captionId, caption, sizeof(caption)/sizeof(caption[0]));
- LoadStringW(GetModuleHandleW(NULL), textId, text, sizeof(text)/sizeof(text[0]));
+ LoadStringW(GetModuleHandleW(NULL), captionId, caption, ARRAY_SIZE(caption));
+ LoadStringW(GetModuleHandleW(NULL), textId, text, ARRAY_SIZE(text));
return MessageBoxW(hwnd, text, caption, uType);
}
@@ -116,8 +116,7 @@ static void set_message_with_filename(HWND hDlg)
WCHAR originalText[1000];
WCHAR newText[1000 + MAX_PROGRAM_NAME_LENGTH];
- GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText,
- sizeof(originalText)/sizeof(originalText[0]));
+ GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText, ARRAY_SIZE(originalText));
wsprintfW(newText, originalText, g_ProgramName);
SetDlgItemTextW(hDlg, IDC_STATIC_TXT1, newText);
}
@@ -150,11 +149,11 @@ static void save_crash_log( HWND hwnd )
memset( &save, 0, sizeof(save) );
lstrcpyW( path, default_name );
- LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, sizeof(buffer)/sizeof(buffer[0]) );
+ LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, ARRAY_SIZE(buffer));
p = buffer + lstrlenW(buffer) + 1;
lstrcpyW(p, txt_files);
p += lstrlenW(p) + 1;
- LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, sizeof(buffer)/sizeof(buffer[0]) - (p - buffer) );
+ LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, ARRAY_SIZE(buffer) - (p - buffer) );
p += lstrlenW(p) + 1;
lstrcpyW(p, all_files);
p += lstrlenW(p) + 1;
@@ -189,7 +188,7 @@ static void save_crash_log( HWND hwnd )
}
else err = GetLastError();
- LoadStringW( GetModuleHandleW(0), IDS_SAVE_ERROR, buffer, sizeof(buffer)/sizeof(WCHAR) );
+ LoadStringW( GetModuleHandleW(0), IDS_SAVE_ERROR, buffer, ARRAY_SIZE(buffer));
FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPWSTR)&p, 0, NULL);
MessageBoxW( 0, p, buffer, MB_OK | MB_ICONERROR);
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 7f59ce1df6..b8387fe0ec 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -391,7 +391,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect(gdbctx->process,
de->u.CreateProcessInfo.lpImageName,
de->u.CreateProcessInfo.fUnicode,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR));
+ u.buffer, ARRAY_SIZE(u.buffer));
dbg_set_process_name(gdbctx->process, u.buffer);
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
@@ -423,7 +423,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect(gdbctx->process,
de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR));
+ u.buffer, ARRAY_SIZE(u.buffer));
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
fprintf(stderr, "%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
@@ -1146,7 +1146,7 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
if (gdbctx->trace & GDBPXY_TRC_COMMAND)
fprintf(stderr, "trying to process a verbose packet %*.*s\n",
gdbctx->in_packet_len, gdbctx->in_packet_len, gdbctx->in_packet);
- for (i = 0; i < sizeof(verbose_details)/sizeof(verbose_details[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(verbose_details); i++)
{
if (klen == verbose_details[i].len &&
!memcmp(gdbctx->in_packet, verbose_details[i].name, verbose_details[i].len))
@@ -1934,11 +1934,11 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
assert(plen);
/* FIXME: should use bsearch if packet_entries was sorted */
- for (i = 0; i < sizeof(packet_entries)/sizeof(packet_entries[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(packet_entries); i++)
{
if (packet_entries[i].key == gdbctx->in_buf[1]) break;
}
- if (i == sizeof(packet_entries)/sizeof(packet_entries[0]))
+ if (i == ARRAY_SIZE(packet_entries))
{
if (gdbctx->trace & GDBPXY_TRC_COMMAND_ERROR)
fprintf(stderr, "Unknown packet request %*.*s\n",
@@ -2178,7 +2178,7 @@ static BOOL gdb_init_context(struct gdb_context* gdbctx, unsigned flags, unsigne
gdbctx->in_trap = FALSE;
gdbctx->trace = /*GDBPXY_TRC_PACKET | GDBPXY_TRC_COMMAND |*/ GDBPXY_TRC_COMMAND_ERROR | GDBPXY_TRC_COMMAND_FIXME | GDBPXY_TRC_WIN32_EVENT;
gdbctx->process = NULL;
- for (i = 0; i < sizeof(gdbctx->wine_segs) / sizeof(gdbctx->wine_segs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(gdbctx->wine_segs); i++)
gdbctx->wine_segs[i] = 0;
/* wait for first trap */
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index e5fd07da92..c5569e6adf 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -360,7 +360,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name(de->u.CreateProcessInfo.lpImageName,
de->u.CreateProcessInfo.fUnicode,
de->u.CreateProcessInfo.lpBaseOfImage,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR), TRUE);
+ u.buffer, ARRAY_SIZE(u.buffer), TRUE);
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
@@ -455,7 +455,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name(de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
de->u.LoadDll.lpBaseOfDll,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR), FALSE);
+ u.buffer, ARRAY_SIZE(u.buffer), FALSE);
WINE_TRACE("%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
@@ -708,7 +708,7 @@ static const char *get_windows_version(void)
GetVersionExW( (OSVERSIONINFOW *)&info );
- for (i = 0; i < sizeof(version_table) / sizeof(version_table[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(version_table); i++)
{
if (version_table[i].type == info.wProductType &&
version_table[i].platform == info.dwPlatformId &&
--
2.14.4
June 17, 2018
Re: [PATCH 2/2] user32/tests: Skip tests for window messages if we failed to receive foreground status.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39204
Your paranoid android.
=== w7pro64 (64 bit input) ===
input.c:2055: Test failed: expected WM_NCHITTEST message
input.c:2082: Test failed: expected loop with WM_NCHITTEST messages
input.c:2135: Test failed: expected WM_LBUTTONDOWN message
input.c:2136: Test failed: expected WM_LBUTTONUP message
June 17, 2018
[PATCH 2/2] user32/tests: Skip tests for window messages if we failed to receive foreground status.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
This should be a better way of checking for failure since it addresses the
root cause, and should hopefully also fix an intermittent test failure on
Wine.
dlls/user32/tests/input.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 2185cda..8fa1de2 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -691,14 +691,17 @@ static struct message sent_messages[MAXKEYMESSAGES];
static UINT sent_messages_cnt;
/* Verify that only specified key state transitions occur */
-static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test)
+static void compare_and_check(int id, BYTE *ks1, BYTE *ks2,
+ const struct sendinput_test_s *test, BOOL foreground)
{
int i, failcount = 0;
const struct transition_s *t = test->expected_transitions;
UINT actual_cnt = 0;
const struct message *expected = test->expected_messages;
- while (t->wVk) {
+ while (t->wVk && foreground) {
+ /* We won't receive any information from GetKeyboardState() if we're
+ * not the foreground window. */
BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80)
&& (ks2[t->wVk]&0x80) == (~t->before_state&0x80));
@@ -781,6 +784,13 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp
expected++;
continue;
}
+ else if (!(expected->flags & hook) && !foreground)
+ {
+ /* If we weren't able to receive foreground status, we won't get
+ * any window messages. */
+ expected++;
+ continue;
+ }
/* NT4 doesn't send SYSKEYDOWN/UP to hooks, only KEYDOWN/UP */
else if ((expected->flags & hook) &&
(expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
@@ -817,7 +827,7 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp
expected++;
}
/* skip all optional trailing messages */
- while (expected->message && (expected->flags & optional))
+ while (expected->message && ((expected->flags & optional) || (!(expected->flags & hook) && !foreground)))
expected++;
@@ -897,6 +907,7 @@ static void test_Input_blackbox(void)
int ii;
BYTE ks1[256], ks2[256];
LONG_PTR prevWndProc;
+ BOOL foreground;
HWND window;
HHOOK hook;
@@ -910,7 +921,9 @@ static void test_Input_blackbox(void)
NULL, NULL);
ok(window != NULL, "error: %d\n", (int) GetLastError());
SetWindowPos( window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
- SetForegroundWindow( window );
+ foreground = SetForegroundWindow( window );
+ if (!foreground)
+ skip("Failed to set foreground window; some tests will be skipped.\n");
if (!(hook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, GetModuleHandleA( NULL ), 0)))
{
@@ -939,15 +952,7 @@ static void test_Input_blackbox(void)
pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
empty_message_queue();
GetKeyboardState(ks2);
- if (!ii && sent_messages_cnt <= 1 && !memcmp( ks1, ks2, sizeof(ks1) ))
- {
- win_skip( "window doesn't receive the queued input\n" );
- /* release the key */
- i.u.ki.dwFlags |= KEYEVENTF_KEYUP;
- pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
- break;
- }
- compare_and_check(ii, ks1, ks2, &sendinput_test[ii]);
+ compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground);
}
empty_message_queue();
--
2.7.4
June 17, 2018
[PATCH 1/2] user32/tests: Ignore all non-keyboard messages in test_Input_blackbox().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/user32/tests/input.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index e52f7d2..2185cda 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -848,16 +848,7 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam,
{
if (winetest_debug > 1) trace("MSG: %8x W:%8lx L:%8lx\n", Msg, wParam, lParam);
- if (Msg != WM_PAINT &&
- Msg != WM_NCPAINT &&
- Msg != WM_SYNCPAINT &&
- Msg != WM_ERASEBKGND &&
- Msg != WM_NCHITTEST &&
- Msg != WM_GETTEXT &&
- Msg != WM_GETICON &&
- Msg != WM_IME_SELECT &&
- Msg != WM_DEVICECHANGE &&
- Msg != WM_TIMECHANGE)
+ if ((Msg >= WM_KEYFIRST && Msg <= WM_KEYLAST) || Msg == WM_SYSCOMMAND)
{
ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n");
if (sent_messages_cnt < MAXKEYMESSAGES)
--
2.7.4
June 17, 2018