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
[PATCH] winhttp/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/winhttp/tests/notification.c | 20 ++++++++++----------
dlls/winhttp/tests/winhttp.c | 24 ++++++++++++------------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c
index 2a647e3633..086f2e7935 100644
--- a/dlls/winhttp/tests/notification.c
+++ b/dlls/winhttp/tests/notification.c
@@ -187,7 +187,7 @@ static void test_connection_cache( void )
struct info info, *context = &info;
info.test = cache_test;
- info.count = sizeof(cache_test) / sizeof(cache_test[0]);
+ info.count = ARRAY_SIZE( cache_test );
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -427,7 +427,7 @@ static void test_redirect( void )
struct info info, *context = &info;
info.test = redirect_test;
- info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
+ info.count = ARRAY_SIZE( redirect_test );
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -508,7 +508,7 @@ static void test_async( void )
char buffer[1024];
info.test = async_test;
- info.count = sizeof(async_test) / sizeof(async_test[0]);
+ info.count = ARRAY_SIZE( async_test );
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -779,12 +779,12 @@ static void open_async_request(int port, struct test_request *req, struct info *
if (reuse_connection)
{
info->test = reuse_socket_request_test;
- info->count = sizeof(reuse_socket_request_test) / sizeof(reuse_socket_request_test[0]);
+ info->count = ARRAY_SIZE( reuse_socket_request_test );
}
else
{
info->test = open_socket_request_test;
- info->count = sizeof(open_socket_request_test) / sizeof(open_socket_request_test[0]);
+ info->count = ARRAY_SIZE( open_socket_request_test );
}
req->session = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
@@ -830,7 +830,7 @@ static void server_send_reply(struct test_request *req, struct info *info, const
WaitForSingleObject( info->wait, INFINITE );
info->test = server_reply_test;
- info->count = sizeof(server_reply_test) / sizeof(server_reply_test[0]);
+ info->count = ARRAY_SIZE( server_reply_test );
info->index = 0;
setup_test( info, winhttp_send_request, __LINE__ );
ret = WinHttpReceiveResponse( req->request, NULL );
@@ -879,12 +879,12 @@ static void close_request(struct test_request *req, struct info *info, BOOL allo
if (allow_closing_connection)
{
info->test = close_allow_connection_close_request_test;
- info->count = sizeof(close_allow_connection_close_request_test)/sizeof(*close_allow_connection_close_request_test);
+ info->count = ARRAY_SIZE( close_allow_connection_close_request_test );
}
else
{
info->test = close_request_test;
- info->count = sizeof(close_request_test)/sizeof(*close_request_test);
+ info->count = ARRAY_SIZE( close_request_test );
}
info->index = 0;
setup_test( info, winhttp_close_handle, __LINE__ );
@@ -926,12 +926,12 @@ static void _read_request_data(struct test_request *req, struct info *info, cons
if (closing_connection)
{
info->test = read_allow_close_test;
- info->count = sizeof(read_allow_close_test)/sizeof(*read_allow_close_test);
+ info->count = ARRAY_SIZE( read_allow_close_test );
}
else
{
info->test = read_test;
- info->count = sizeof(read_test)/sizeof(*read_test);
+ info->count = ARRAY_SIZE( read_test );
}
info->index = 0;
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 4b4a84c5fc..46504e1b0c 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -2907,7 +2907,7 @@ static void test_not_modified(int port)
memcpy(today, ifmodifiedW, sizeof(ifmodifiedW));
GetSystemTime(&st);
- WinHttpTimeFromSystemTime(&st, &today[sizeof(ifmodifiedW)/sizeof(WCHAR)]);
+ WinHttpTimeFromSystemTime(&st, &today[ARRAY_SIZE(ifmodifiedW)]);
session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY,
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
@@ -3277,13 +3277,13 @@ static void test_credentials(void)
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
ok(req != NULL, "failed to open a request %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_USERNAME, &buffer, &size);
ok(ret, "failed to query proxy username %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
ok(!size, "expected 0, got %u\n", size);
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_PASSWORD, &buffer, &size);
ok(ret, "failed to query proxy password %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3292,19 +3292,19 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_USERNAME, proxy_userW, lstrlenW(proxy_userW));
ok(ret, "failed to set username %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_USERNAME, &buffer, &size);
ok(ret, "failed to query proxy username %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %u\n", size);
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
ok(ret, "failed to query username %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
ok(!size, "expected 0, got %u\n", size);
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
ok(ret, "failed to query password %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3313,7 +3313,7 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_PASSWORD, proxy_passW, lstrlenW(proxy_passW));
ok(ret, "failed to set proxy password %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_PASSWORD, &buffer, &size);
ok(ret, "failed to query proxy password %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3322,7 +3322,7 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
ok(ret, "failed to set username %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
ok(ret, "failed to query username %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3331,7 +3331,7 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
ok(ret, "failed to set password %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
ok(ret, "failed to query password %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3357,7 +3357,7 @@ static void test_credentials(void)
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, userW, passW, NULL);
ok(ret, "failed to set credentials %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
ok(ret, "failed to query username %u\n", GetLastError());
todo_wine {
@@ -3365,7 +3365,7 @@ static void test_credentials(void)
ok(!size, "expected 0, got %u\n", size);
}
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
ok(ret, "failed to query password %u\n", GetLastError());
todo_wine {
@@ -3920,7 +3920,7 @@ static void test_IWinHttpRequest(int port)
ok( hr == S_OK, "got %08x\n", hr );
sprintf( buf, "http://localhost:%d/auth", port );
- MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, sizeof(bufW)/sizeof(bufW[0]) );
+ MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, ARRAY_SIZE( bufW ));
url = SysAllocString( bufW );
method = SysAllocString( method3W );
V_VT( &async ) = VT_BOOL;
--
2.14.4
June 11, 2018
Re: [PATCH 1/3] msvcrt: Add _crt_at_quick_exit stub
by Piotr Caban
On 06/11/18 23:02, Fabian Maurer wrote:
> Hi Piotr,
>
> > The func argument should probably use CDECL calling convention (not that
>
> > it really matters in case of no-arguments function).
>
> I did it like MSVCRT__crt_atexit did it, first pass the func like this
> and then cast to MSVCRT__onexit_t. Should I make it MSVCRT__onexit_t
> right away?
I think it's better to keep function header the same as in native. Could
you please also change MSVCRT__crt_atexit header while you're at it?
Thanks,
Piotr
June 11, 2018
Re: [PATCH 3/3] msvcrt: Implement quick_exit and _crt_at_quick_exit
by Piotr Caban
Hi,
On 06/05/18 22:42, Fabian Maurer wrote:
> Code taken from onexit logic and adapted-
Why don't you just call onexit functions instead of reimplementing it?
Note that you don't need to call MSVCRT__initialize_onexit_table when
quick_exit table is declared static.
Thanks,
Piotr
June 11, 2018
Re: [PATCH 2/3] msvcrt: Add quick_exit
by Piotr Caban
Hi,
On 06/05/18 22:42, Fabian Maurer wrote:
> +/*********************************************************************
> + * quick_exit (MSVCRT.@)
> + */
> +void CDECL MSVCRT_quick_exit(int exitcode)
> +{
> + FIXME("partial stub: (%d)\n", exitcode);
> + MSVCRT__exit(exitcode);
> +}
quick_exit function should not call exit. I'm attaching a test that
shows that atexit callbacks should not be called.
Thanks,
Piotr
June 11, 2018
Re: [PATCH 1/3] msvcrt: Add _crt_at_quick_exit stub
by Fabian Maurer
Hi Piotr,
> The func argument should probably use CDECL calling convention (not that
> it really matters in case of no-arguments function).
I did it like MSVCRT__crt_atexit did it, first pass the func like this and then cast to
MSVCRT__onexit_t. Should I make it MSVCRT__onexit_t right away?
> Also it's probably better to return -1 (error) in stub.
Sure can do, although it doesn't matter too much since I later replace it anyways.
Regards,
Fabian Maurer
June 11, 2018
Re: [PATCH 4/5] msvcrt: Avoid using inline assembly in call_unwind_func().
by Zebediah Figura
On 06/11/2018 11:48 AM, Piotr Caban wrote:
> Hi Zeb,
>
> On 06/05/18 00:23, Zebediah Figura wrote:
>> +extern int call_unwind_func( int (*func)(void), void *ebp );
>> +
>> +__ASM_GLOBAL_FUNC( call_unwind_func,
>> + "pushl %ebp\n\t"
>> + "pushl %ebx\n\t"
>> + "pushl %esi\n\t"
>> + "pushl %edi\n\t"
>> + "movl 24(%esp), %ebp\n\t"
>> + "call *20(%esp)\n\t"
>> + "popl %edi\n\t"
>> + "popl %esi\n\t"
>> + "popl %ebx\n\t"
>> + "popl %ebp\n\t"
>> + "ret" );
>
> How about renaming the function to call_handler and returning void* from
> it? It looks strange that in all places where return value is used we
> need to cast it to pointer.
>
> Thanks,
> Piotr
Thanks; I'll send an updated patch.
June 11, 2018
Re: [PATCH 1/3] msvcrt: Add _crt_at_quick_exit stub
by Piotr Caban
Hi Fabian,
On 06/05/18 22:42, Fabian Maurer wrote:
> +/*********************************************************************
> + * _crt_at_quick_exit (UCRTBASE.@)
> + */
> +int CDECL MSVCRT__crt_at_quick_exit(void (*func)(void))
> +{
> + FIXME("stub: (%p)\n", func);
> + return 0;
> +}
The func argument should probably use CDECL calling convention (not that
it really matters in case of no-arguments function). Also it's probably
better to return -1 (error) in stub.
Thanks,
Piotr
June 11, 2018
Re: [PATCH] vcomp/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
I already sent this patch in as 146709.
It is pending Sebastian's signed off.
bye
michael
On 06/11/2018 09:33 PM, André Hentschel wrote:
> Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
> ---
> dlls/vcomp/tests/vcomp.c | 56 ++++++++++++++++++++++++------------------------
> 1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/dlls/vcomp/tests/vcomp.c b/dlls/vcomp/tests/vcomp.c
> index 154744b..ea62909 100644
> --- a/dlls/vcomp/tests/vcomp.c
> +++ b/dlls/vcomp/tests/vcomp.c
> @@ -766,7 +766,7 @@ static void CDECL for_static_simple_cb(void)
> int thread_num = pomp_get_thread_num();
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned int my_begin, my_end, begin, end;
>
> @@ -966,7 +966,7 @@ static void CDECL for_static_cb(void)
> int thread_num = pomp_get_thread_num();
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> int my_begin, my_end, my_next, my_lastchunk;
> int begin, end, next, lastchunk;
> @@ -1614,25 +1614,25 @@ static void test_atomic_integer8(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> char val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> char val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> ok(val == tests2[i].expected, "test %d: expected val == %d, got %d\n", i, tests2[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests3); i++)
> {
> unsigned char val = tests3[i].v1;
> tests3[i].func(&val, tests3[i].v2);
> ok(val == tests3[i].expected, "test %d: expected val == %u, got %u\n", i, tests3[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests4); i++)
> {
> unsigned char val = tests4[i].v1;
> tests4[i].func(&val, tests4[i].v2);
> @@ -1707,25 +1707,25 @@ static void test_atomic_integer16(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> short val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> short val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> ok(val == tests2[i].expected, "test %d: expected val == %d, got %d\n", i, tests2[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests3); i++)
> {
> unsigned short val = tests3[i].v1;
> tests3[i].func(&val, tests3[i].v2);
> ok(val == tests3[i].expected, "test %d: expected val == %u, got %u\n", i, tests3[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests4); i++)
> {
> unsigned short val = tests4[i].v1;
> tests4[i].func(&val, tests4[i].v2);
> @@ -1777,13 +1777,13 @@ static void test_atomic_integer32(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> int val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> unsigned int val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> @@ -1871,26 +1871,26 @@ static void test_atomic_integer64(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> LONG64 val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> LONG64 val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> todo_wine_if(tests2[i].todo)
> ok(val == tests2[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests3); i++)
> {
> ULONG64 val = tests3[i].v1;
> tests3[i].func(&val, tests3[i].v2);
> ok(val == tests3[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests4); i++)
> {
> ULONG64 val = tests4[i].v1;
> tests4[i].func(&val, tests4[i].v2);
> @@ -1915,7 +1915,7 @@ static void test_atomic_float(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> float val = tests[i].v1;
> tests[i].func(&val, tests[i].v2);
> @@ -1940,7 +1940,7 @@ static void test_atomic_double(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> double val = tests[i].v1;
> tests[i].func(&val, tests[i].v2);
> @@ -1978,13 +1978,13 @@ static void test_reduction_integer8(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> char val = tests[i].v1;
> p_vcomp_reduction_i1(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: expected val == %d, got %d\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned char val = tests[i].v1;
> p_vcomp_reduction_u1(tests[i].flags, &val, tests[i].v2);
> @@ -2022,13 +2022,13 @@ static void test_reduction_integer16(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> short val = tests[i].v1;
> p_vcomp_reduction_i2(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: expected val == %d, got %d\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned short val = tests[i].v1;
> p_vcomp_reduction_u2(tests[i].flags, &val, tests[i].v2);
> @@ -2105,13 +2105,13 @@ static void test_reduction_integer32(void)
>
> pomp_set_num_threads(max_threads);
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> int val = tests[i].v1;
> p_vcomp_reduction_i4(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: expected val == %d, got %d\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned int val = tests[i].v1;
> p_vcomp_reduction_u4(tests[i].flags, &val, tests[i].v2);
> @@ -2148,13 +2148,13 @@ static void test_reduction_integer64(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> LONG64 val = tests[i].v1;
> p_vcomp_reduction_i8(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> ULONG64 val = tests[i].v1;
> p_vcomp_reduction_u8(tests[i].flags, &val, tests[i].v2);
> @@ -2206,14 +2206,14 @@ static void test_reduction_float_double(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> float val = tests[i].v1;
> p_vcomp_reduction_r4(tests[i].flags, &val, tests[i].v2);
> ok(tests[i].expected - 0.001 < val && val < tests[i].expected + 0.001,
> "test %d: expected val == %f, got %f\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> double val = tests[i].v1;
> p_vcomp_reduction_r8(tests[i].flags, &val, tests[i].v2);
>
June 11, 2018
Re: [PATCH] ws2_32/tests: Use the available ARRAY_SIZE() macro
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=39073
Your paranoid android.
=== w7u (32 bit sock) ===
sock.c:10956: Test failed: got 0
sock.c:10957: Test failed: got 00000000
sock.c:10958: Test failed: got 0000
sock.c:10959: Test failed: got 00000000
sock.c:10960: Test failed: got 00000000
sock.c:10970: Test failed: got 0464,000002f4,00000002
=== w1064 (64 bit sock) ===
sock.c:8629: Test failed: bytesReturned isn't supposed to be 1
sock.c:8653: Test failed: GetOverlappedResult failed, error 0
June 11, 2018
[PATCH] ws2_32/tests: Use the available ARRAY_SIZE() macro
by André Hentschel
Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
---
dlls/ws2_32/tests/protocol.c | 4 +--
dlls/ws2_32/tests/sock.c | 58 +++++++++++++++++++++-----------------------
2 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index 9c6d80d..99bd137 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -113,7 +113,7 @@ static void test_WSAEnumProtocolsA(void)
ok( ret >= 2, "Expected at least 2 items, received %d\n", ret);
for (i = found = 0; i < ret; i++)
- for (j = 0; j < sizeof(ptest) / sizeof(ptest[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(ptest); j++)
if (buffer[i].iProtocol == ptest[j])
{
found |= 1 << j;
@@ -180,7 +180,7 @@ static void test_WSAEnumProtocolsW(void)
ok( ret >= 2, "Expected at least 2 items, received %d\n", ret);
for (i = found = 0; i < ret; i++)
- for (j = 0; j < sizeof(ptest) / sizeof(ptest[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(ptest); j++)
if (buffer[i].iProtocol == ptest[j])
{
found |= 1 << j;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 6dd1491..b32d1c0 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1191,7 +1191,7 @@ static void test_WithWSAStartup(void)
ok(ptr != NULL, "gethostbyname() failed unexpectedly: %d\n", WSAGetLastError());
/* Alloc some sockets to check if they are destroyed on WSACleanup */
- for (socks = 0; socks < sizeof(pairs) / sizeof(pairs[0]); socks++)
+ for (socks = 0; socks < ARRAY_SIZE(pairs); socks++)
{
WSAPROTOCOL_INFOA info;
if (tcp_socketpair(&pairs[socks].src, &pairs[socks].dst)) break;
@@ -1471,7 +1471,7 @@ static void test_set_getsockopt(void)
todo_wine ok( value == 4096, "expected 4096, got %u\n", value );
/* SO_LINGER */
- for( i = 0; i < sizeof(linger_testvals)/sizeof(LINGER);i++) {
+ for( i = 0; i < ARRAY_SIZE(linger_testvals);i++) {
size = sizeof(lingval);
lingval = linger_testvals[i];
err = setsockopt(s, SOL_SOCKET, SO_LINGER, (char *) &lingval, size);
@@ -1630,7 +1630,7 @@ todo_wine
closesocket(s);
/* test SO_PROTOCOL_INFO structure returned for different protocols */
- for (i = 0; i < sizeof(prottest) / sizeof(prottest[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(prottest); i++)
{
int k;
@@ -2083,7 +2083,7 @@ static void test_ip_pktinfo(void)
/* Note: hdr.Control.len is set below */
hdr.dwFlags = 0;
- for (i=0;i<sizeof(addresses)/sizeof(UINT32);i++)
+ for (i=0;i<ARRAY_SIZE(addresses);i++)
{
s1addr.sin_addr.s_addr = addresses[i];
@@ -2689,7 +2689,7 @@ static void test_WSASocket(void)
/* when no socket type is specified the first entry from WSAEnumProtocols
* that matches the protocol is returned */
- for (i = 0; i < sizeof(autoprotocols) / sizeof(autoprotocols[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(autoprotocols); i++)
{
sock = WSASocketA(0, 0, autoprotocols[i], NULL, 0, 0);
ok(sock != INVALID_SOCKET, "Failed to create socket for protocol %d, received %d\n",
@@ -3010,7 +3010,7 @@ static void test_WSAEnumNetworkEvents(void)
/* This test follows the steps from bugs 10204 and 24946 */
for (l = 0; l < 2; l++)
{
- for (i = 0; i < sizeof(sock_type) / sizeof(sock_type[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(sock_type); i++)
{
if (i == 2)
ok(!tcp_socketpair(&s, &s2), "Test[%d]: creating socket pair failed\n", i);
@@ -3280,7 +3280,7 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address, expect1 ), "Expected different address string\n" );
- ok( len == sizeof( expect1 )/sizeof( WCHAR ), "Got size %d\n", len);
+ ok( len == ARRAY_SIZE(expect1), "Got size %d\n", len);
len = sizeof(address);
@@ -3314,7 +3314,7 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address, expect4 ), "Expected different address string\n" );
- ok( len == sizeof( expect4 )/sizeof( WCHAR ), "Got %d\n", len);
+ ok( len == ARRAY_SIZE(expect4), "Got %d\n", len);
/*check to see it IPv6 is available */
v6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
@@ -3325,7 +3325,7 @@ static void test_WSAAddressToStringW(void)
}
/* Test a short IPv6 address */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0x0000;
@@ -3335,10 +3335,10 @@ static void test_WSAAddressToStringW(void)
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_1 ), "Wrong string returned\n" );
- ok( len == sizeof(expect6_1)/sizeof(WCHAR), "Got %d\n", len);
+ ok( len == ARRAY_SIZE(expect6_1), "Got %d\n", len);
/* Test a longer IPv6 address */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0x0000;
@@ -3349,10 +3349,10 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_2 ), "Wrong string returned\n" );
- ok( len == sizeof(expect6_2)/sizeof(WCHAR), "Got %d\n", len);
+ ok( len == ARRAY_SIZE(expect6_2), "Got %d\n", len);
/* Test IPv6 address and port number */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0xfa81;
@@ -3363,10 +3363,10 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_3 ),
"Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3), wine_dbgstr_w(address6) );
- ok( len == sizeof(expect6_3)/sizeof(WCHAR), "Got %d\n", len );
+ ok( len == ARRAY_SIZE(expect6_3), "Got %d\n", len );
/* Test IPv6 address, port number and scope_id */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0xfa81;
@@ -3377,10 +3377,10 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_3_2 ),
"Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_2), wine_dbgstr_w(address6) );
- ok( len == sizeof(expect6_3_2)/sizeof(WCHAR), "Got %d\n", len );
+ ok( len == ARRAY_SIZE(expect6_3_2), "Got %d\n", len );
/* Test IPv6 address and scope_id */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0x0000;
@@ -3391,7 +3391,7 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_3_3 ),
"Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_3), wine_dbgstr_w(address6) );
- ok( len == sizeof(expect6_3_3)/sizeof(WCHAR), "Got %d\n", len );
+ ok( len == ARRAY_SIZE(expect6_3_3), "Got %d\n", len );
end:
if (v6 != INVALID_SOCKET)
@@ -5112,7 +5112,7 @@ static void test_inet_pton(void)
return;
}
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
WSASetLastError(0xdeadbeef);
ret = pInetPtonA(tests[i].family, tests[i].printable, buffer);
@@ -5137,11 +5137,10 @@ static void test_inet_pton(void)
i, tests[i].collapsed, ptr);
}
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
if (tests[i].printable)
- MultiByteToWideChar(CP_ACP, 0, tests[i].printable, -1, printableW,
- sizeof(printableW) / sizeof(printableW[0]));
+ MultiByteToWideChar(CP_ACP, 0, tests[i].printable, -1, printableW, ARRAY_SIZE(printableW));
WSASetLastError(0xdeadbeef);
ret = pInetPtonW(tests[i].family, tests[i].printable ? printableW : NULL, buffer);
ok(ret == tests[i].ret, "Test [%d]: Expected %d, got %d\n", i, tests[i].ret, ret);
@@ -5157,13 +5156,12 @@ static void test_inet_pton(void)
/* Test the result from Pton with Ntop */
printableW[0] = 0xdead;
- ptrW = pInetNtopW(tests[i].family, buffer, printableW, sizeof(printableW) / sizeof(printableW[0]));
+ ptrW = pInetNtopW(tests[i].family, buffer, printableW, ARRAY_SIZE(printableW));
ok (ptrW != NULL, "Test [%d]: Failed with NULL\n", i);
ok (ptrW == printableW, "Test [%d]: Pointers differ (%p != %p)\n", i, ptrW, printableW);
if (!ptrW) continue;
- MultiByteToWideChar(CP_ACP, 0, tests[i].collapsed, -1, collapsedW,
- sizeof(collapsedW) / sizeof(collapsedW[0]));
+ MultiByteToWideChar(CP_ACP, 0, tests[i].collapsed, -1, collapsedW, ARRAY_SIZE(collapsedW));
ok (lstrcmpW(ptrW, collapsedW) == 0, "Test [%d]: Expected '%s', got '%s'\n",
i, tests[i].collapsed, wine_dbgstr_w(ptrW));
}
@@ -5189,7 +5187,7 @@ static void test_ioctlsocket(void)
return;
}
- for(i = 0; i < sizeof(cmds)/sizeof(cmds[0]); i++)
+ for(i = 0; i < ARRAY_SIZE(cmds); i++)
{
/* broken apps like defcon pass the argp value directly instead of a pointer to it */
ret = ioctlsocket(sock, cmds[i], (u_long *)1);
@@ -7345,7 +7343,7 @@ static void test_GetAddrInfoW(void)
int i, ret;
ADDRINFOW *result, *result2, *p, hint;
WCHAR name[256];
- DWORD size = sizeof(name)/sizeof(WCHAR);
+ DWORD size = ARRAY_SIZE(name);
/* te su to.winehq.org written in katakana */
static const WCHAR idn_domain[] =
{0x30C6,0x30B9,0x30C8,'.','w','i','n','e','h','q','.','o','r','g',0};
@@ -7483,7 +7481,7 @@ static void test_GetAddrInfoW(void)
ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
ok(result == NULL, "got %p\n", result);
- for (i = 0;i < (sizeof(hinttests) / sizeof(hinttests[0]));i++)
+ for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
{
hint.ai_family = hinttests[i].family;
hint.ai_socktype = hinttests[i].socktype;
@@ -7939,7 +7937,7 @@ static void test_getaddrinfo(void)
hint.ai_flags = 0;
- for (i = 0;i < (sizeof(hinttests) / sizeof(hinttests[0]));i++)
+ for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
{
hint.ai_family = hinttests[i].family;
hint.ai_socktype = hinttests[i].socktype;
@@ -11504,7 +11502,7 @@ START_TEST( sock )
test_ip_pktinfo();
test_extendedSocketOptions();
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
trace ( " **** STARTING TEST %d ****\n", i );
do_test ( &tests[i] );
--
2.7.4
June 11, 2018