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/5] mstask: Implement IEnumWorkItems::Next().
by Alexandre Julliard
Dmitry Timoshkov <dmitry(a)baikal.ru> writes:
> + if (is_file(&data))
> + {
> + LPWSTR *new_list;
> +
> + if (!list)
> + new_list = CoTaskMemAlloc((enumerated + 1) * sizeof(list[0]));
> + else
> + new_list = CoTaskMemRealloc(list, (enumerated + 1) * sizeof(list[0]));
It would be better to double the allocated size.
--
Alexandre Julliard
julliard(a)winehq.org
June 11, 2018
[PATCH] ntdll: Implement RtlReleaseRelativeName
by Stefan Leichter
For https://bugs.winehq.org/show_bug.cgi?id=45294
Signed-off-by: Stefan Leichter <sle85276(a)gmx.de>
---
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/path.c | 8 ++++++++
2 files changed, 9 insertions(+)
June 11, 2018
[PATCH 2/2] user32: Fix returned class name for other processes windows.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/user32/class.c | 18 ++++++++++--------
include/wine/server_protocol.h | 18 +++++++++++++++++-
server/atom.c | 25 +++++++++++++++++++++++++
server/class.c | 5 +++++
server/object.h | 1 +
server/protocol.def | 8 ++++++++
server/request.h | 5 +++++
server/trace.c | 13 +++++++++++++
server/user.h | 1 +
server/window.c | 17 +++++++++++++++++
10 files changed, 102 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index 2b2d07f888..69dc4477ca 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -1183,7 +1183,7 @@ INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
{
CLASS *class;
- INT ret;
+ INT ret = 0;
TRACE("%p %p %d\n", hwnd, buffer, count);
@@ -1193,15 +1193,17 @@ INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
if (class == CLASS_OTHER_PROCESS)
{
- WCHAR tmpbuf[MAX_ATOM_LEN + 1];
-
- ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), tmpbuf, MAX_ATOM_LEN + 1 );
- if (ret)
+ SERVER_START_REQ( get_class_name )
{
- ret = min(count - 1, ret);
- memcpy(buffer, tmpbuf, ret * sizeof(WCHAR));
- buffer[ret] = 0;
+ req->handle = wine_server_user_handle( hwnd );
+ wine_server_set_reply( req, buffer, count * sizeof(WCHAR) );
+ if (!wine_server_call_err( req ))
+ {
+ ret = wine_server_reply_size( reply );
+ buffer[ret / sizeof(WCHAR)] = 0;
+ }
}
+ SERVER_END_REQ;
}
else
{
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 5358af20b8..879d361ab2 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -3503,6 +3503,19 @@ struct set_window_owner_reply
+struct get_class_name_request
+{
+ struct request_header __header;
+ user_handle_t handle;
+};
+struct get_class_name_reply
+{
+ struct reply_header __header;
+ /* VARARG(name,unicode_str); */
+};
+
+
+
struct get_window_info_request
{
struct request_header __header;
@@ -5793,6 +5806,7 @@ enum request
REQ_destroy_window,
REQ_get_desktop_window,
REQ_set_window_owner,
+ REQ_get_class_name,
REQ_get_window_info,
REQ_set_window_info,
REQ_set_parent,
@@ -6089,6 +6103,7 @@ union generic_request
struct destroy_window_request destroy_window_request;
struct get_desktop_window_request get_desktop_window_request;
struct set_window_owner_request set_window_owner_request;
+ struct get_class_name_request get_class_name_request;
struct get_window_info_request get_window_info_request;
struct set_window_info_request set_window_info_request;
struct set_parent_request set_parent_request;
@@ -6383,6 +6398,7 @@ union generic_reply
struct destroy_window_reply destroy_window_reply;
struct get_desktop_window_reply get_desktop_window_reply;
struct set_window_owner_reply set_window_owner_reply;
+ struct get_class_name_reply get_class_name_reply;
struct get_window_info_reply get_window_info_reply;
struct set_window_info_reply set_window_info_reply;
struct set_parent_reply set_parent_reply;
@@ -6512,6 +6528,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
-#define SERVER_PROTOCOL_VERSION 554
+#define SERVER_PROTOCOL_VERSION 555
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/atom.c b/server/atom.c
index 3ff75407d9..7e79195973 100644
--- a/server/atom.c
+++ b/server/atom.c
@@ -381,6 +381,31 @@ void release_global_atom( struct winstation *winstation, atom_t atom )
}
}
+/* get atom name */
+int get_atom_string( atom_t atom, WCHAR *name, unsigned short len )
+{
+ struct atom_table *table = get_table( 0, 0 );
+ int ret = 0;
+
+ *name = 0;
+
+ if (table)
+ {
+ struct atom_entry *entry;
+
+ if ((entry = get_atom_entry( table, atom )))
+ {
+ ret = len = min(len, entry->len);
+ memcpy(name, entry->str, len);
+ name[len / sizeof(WCHAR)] = 0;
+ }
+
+ release_object( table );
+ }
+
+ return ret;
+}
+
/* add a global atom */
DECL_HANDLER(add_atom)
{
diff --git a/server/class.c b/server/class.c
index d5f6712006..4bb3aa1aad 100644
--- a/server/class.c
+++ b/server/class.c
@@ -142,6 +142,11 @@ atom_t get_class_atom( struct window_class *class )
return class->atom;
}
+atom_t get_base_class_atom( struct window_class *class )
+{
+ return class->base_atom;
+}
+
client_ptr_t get_class_client_ptr( struct window_class *class )
{
return class->client_ptr;
diff --git a/server/object.h b/server/object.h
index b5c50e1cee..4c8d1a58fd 100644
--- a/server/object.h
+++ b/server/object.h
@@ -224,6 +224,7 @@ extern atom_t add_global_atom( struct winstation *winstation, const struct unico
extern atom_t find_global_atom( struct winstation *winstation, const struct unicode_str *str );
extern int grab_global_atom( struct winstation *winstation, atom_t atom );
extern void release_global_atom( struct winstation *winstation, atom_t atom );
+extern int get_atom_string( atom_t atom, WCHAR *name, unsigned short len );
/* directory functions */
diff --git a/server/protocol.def b/server/protocol.def
index 032b03822b..9027312f46 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -2515,6 +2515,14 @@ enum message_type
@END
+/* Get window class name */
+(a)REQ(get_class_name)
+ user_handle_t handle; /* handle to the window */
+(a)REPLY
+ VARARG(name,unicode_str); /* class name */
+(a)END
+
+
/* Get information from a window handle */
@REQ(get_window_info)
user_handle_t handle; /* handle to the window */
diff --git a/server/request.h b/server/request.h
index 9cf81a1f09..a693e2cf62 100644
--- a/server/request.h
+++ b/server/request.h
@@ -274,6 +274,7 @@ DECL_HANDLER(create_window);
DECL_HANDLER(destroy_window);
DECL_HANDLER(get_desktop_window);
DECL_HANDLER(set_window_owner);
+DECL_HANDLER(get_class_name);
DECL_HANDLER(get_window_info);
DECL_HANDLER(set_window_info);
DECL_HANDLER(set_parent);
@@ -569,6 +570,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_destroy_window,
(req_handler)req_get_desktop_window,
(req_handler)req_set_window_owner,
+ (req_handler)req_get_class_name,
(req_handler)req_get_window_info,
(req_handler)req_set_window_info,
(req_handler)req_set_parent,
@@ -1685,6 +1687,9 @@ C_ASSERT( sizeof(struct set_window_owner_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct set_window_owner_reply, full_owner) == 8 );
C_ASSERT( FIELD_OFFSET(struct set_window_owner_reply, prev_owner) == 12 );
C_ASSERT( sizeof(struct set_window_owner_reply) == 16 );
+C_ASSERT( FIELD_OFFSET(struct get_class_name_request, handle) == 12 );
+C_ASSERT( sizeof(struct get_class_name_request) == 16 );
+C_ASSERT( sizeof(struct get_class_name_reply) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_window_info_request, handle) == 12 );
C_ASSERT( sizeof(struct get_window_info_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_window_info_reply, full_handle) == 8 );
diff --git a/server/trace.c b/server/trace.c
index 999532a425..6b38896f4c 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -3082,6 +3082,16 @@ static void dump_set_window_owner_reply( const struct set_window_owner_reply *re
fprintf( stderr, ", prev_owner=%08x", req->prev_owner );
}
+static void dump_get_class_name_request( const struct get_class_name_request *req )
+{
+ fprintf( stderr, " handle=%08x", req->handle );
+}
+
+static void dump_get_class_name_reply( const struct get_class_name_reply *req )
+{
+ dump_varargs_unicode_str( " name=", cur_size );
+}
+
static void dump_get_window_info_request( const struct get_window_info_request *req )
{
fprintf( stderr, " handle=%08x", req->handle );
@@ -4693,6 +4703,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_destroy_window_request,
(dump_func)dump_get_desktop_window_request,
(dump_func)dump_set_window_owner_request,
+ (dump_func)dump_get_class_name_request,
(dump_func)dump_get_window_info_request,
(dump_func)dump_set_window_info_request,
(dump_func)dump_set_parent_request,
@@ -4985,6 +4996,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
NULL,
(dump_func)dump_get_desktop_window_reply,
(dump_func)dump_set_window_owner_reply,
+ (dump_func)dump_get_class_name_reply,
(dump_func)dump_get_window_info_reply,
(dump_func)dump_set_window_info_reply,
(dump_func)dump_set_parent_reply,
@@ -5277,6 +5289,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"destroy_window",
"get_desktop_window",
"set_window_owner",
+ "get_class_name",
"get_window_info",
"set_window_info",
"set_parent",
diff --git a/server/user.h b/server/user.h
index e7eecd4c6a..11db294fbb 100644
--- a/server/user.h
+++ b/server/user.h
@@ -175,6 +175,7 @@ extern void release_class( struct window_class *class );
extern int is_desktop_class( struct window_class *class );
extern int is_hwnd_message_class( struct window_class *class );
extern atom_t get_class_atom( struct window_class *class );
+extern atom_t get_base_class_atom( struct window_class *class );
extern client_ptr_t get_class_client_ptr( struct window_class *class );
/* windows station functions */
diff --git a/server/window.c b/server/window.c
index 70812095d2..2223d38aeb 100644
--- a/server/window.c
+++ b/server/window.c
@@ -2049,6 +2049,23 @@ DECL_HANDLER(set_window_owner)
}
+/* get class name for a window handle */
+DECL_HANDLER(get_class_name)
+{
+ struct window *win = get_window( req->handle );
+ WCHAR name[256];
+ atom_t atom;
+ int len;
+
+ if (!win) return;
+
+ atom = win->class ? get_base_class_atom( win->class ) : DESKTOP_ATOM;
+ len = get_atom_string(atom, name, 256);
+
+ set_reply_data( name, min( len, get_reply_max_size() ));
+}
+
+
/* get information from a window handle */
DECL_HANDLER(get_window_info)
{
--
2.17.1
June 11, 2018
[PATCH 1/2] server: Use additional atom to keep base class name.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/user32/class.c | 1 +
include/wine/server_protocol.h | 4 +++-
server/class.c | 27 +++++++++++++++++++++++++--
server/protocol.def | 2 ++
server/request.h | 14 ++++++++------
server/trace.c | 2 ++
6 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index ce2830fe25..2b2d07f888 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -487,6 +487,7 @@ static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE
req->win_extra = winExtra;
req->client_ptr = wine_server_client_ptr( classPtr );
req->atom = classPtr->atomName;
+ req->name_offset = basename_offset;
if (!req->atom && name) wine_server_add_data( req, name, strlenW(name) * sizeof(WCHAR) );
ret = !wine_server_call_err( req );
classPtr->atomName = reply->atom;
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 98dbcb7e61..5358af20b8 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -4475,6 +4475,8 @@ struct create_class_request
struct request_header __header;
int local;
atom_t atom;
+ int name_offset;
+ int _pad;
unsigned int style;
mod_handle_t instance;
int extra;
@@ -6510,6 +6512,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
-#define SERVER_PROTOCOL_VERSION 553
+#define SERVER_PROTOCOL_VERSION 554
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/class.c b/server/class.c
index cc6e52d9b1..d5f6712006 100644
--- a/server/class.c
+++ b/server/class.c
@@ -46,6 +46,7 @@ struct window_class
int count; /* reference count */
int local; /* local class? */
atom_t atom; /* class atom */
+ atom_t base_atom; /* base class atom for versioned class */
mod_handle_t instance; /* module instance */
unsigned int style; /* class style */
int win_extra; /* number of window extra bytes */
@@ -151,17 +152,35 @@ DECL_HANDLER(create_class)
{
struct window_class *class;
struct unicode_str name = get_req_unicode_str();
- atom_t atom;
+ atom_t atom, base_atom;
if (name.len)
{
atom = add_global_atom( NULL, &name );
if (!atom) return;
+ if (req->name_offset && req->name_offset < name.len / sizeof(WCHAR))
+ {
+ name.str += req->name_offset;
+ name.len -= req->name_offset * sizeof(WCHAR);
+
+ base_atom = add_global_atom( NULL, &name );
+ if (!base_atom)
+ {
+ release_global_atom( NULL, atom );
+ return;
+ }
+ }
+ else
+ {
+ base_atom = atom;
+ grab_global_atom( NULL, atom );
+ }
}
else
{
- atom = req->atom;
+ base_atom = atom = req->atom;
if (!grab_global_atom( NULL, atom )) return;
+ grab_global_atom( NULL, base_atom );
}
class = find_class( current->process, atom, req->instance );
@@ -169,6 +188,7 @@ DECL_HANDLER(create_class)
{
set_win32_error( ERROR_CLASS_ALREADY_EXISTS );
release_global_atom( NULL, atom );
+ release_global_atom( NULL, base_atom );
return;
}
if (req->extra < 0 || req->extra > 4096 || req->win_extra < 0 || req->win_extra > 4096)
@@ -176,15 +196,18 @@ DECL_HANDLER(create_class)
/* don't allow stupid values here */
set_error( STATUS_INVALID_PARAMETER );
release_global_atom( NULL, atom );
+ release_global_atom( NULL, base_atom );
return;
}
if (!(class = create_class( current->process, req->extra, req->local )))
{
release_global_atom( NULL, atom );
+ release_global_atom( NULL, base_atom );
return;
}
class->atom = atom;
+ class->base_atom = base_atom;
class->instance = req->instance;
class->style = req->style;
class->win_extra = req->win_extra;
diff --git a/server/protocol.def b/server/protocol.def
index 99e7221c4b..032b03822b 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3144,6 +3144,8 @@ enum caret_state
@REQ(create_class)
int local; /* is it a local class? */
atom_t atom; /* class atom */
+ int name_offset; /* base class name offset for specified atom */
+ int _pad;
unsigned int style; /* class style */
mod_handle_t instance; /* module instance */
int extra; /* number of extra class bytes */
diff --git a/server/request.h b/server/request.h
index 2d55dfbd98..9cf81a1f09 100644
--- a/server/request.h
+++ b/server/request.h
@@ -2031,12 +2031,14 @@ C_ASSERT( FIELD_OFFSET(struct get_hook_info_reply, unicode) == 32 );
C_ASSERT( sizeof(struct get_hook_info_reply) == 40 );
C_ASSERT( FIELD_OFFSET(struct create_class_request, local) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_class_request, atom) == 16 );
-C_ASSERT( FIELD_OFFSET(struct create_class_request, style) == 20 );
-C_ASSERT( FIELD_OFFSET(struct create_class_request, instance) == 24 );
-C_ASSERT( FIELD_OFFSET(struct create_class_request, extra) == 32 );
-C_ASSERT( FIELD_OFFSET(struct create_class_request, win_extra) == 36 );
-C_ASSERT( FIELD_OFFSET(struct create_class_request, client_ptr) == 40 );
-C_ASSERT( sizeof(struct create_class_request) == 48 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, name_offset) == 20 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, _pad) == 24 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, style) == 28 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, instance) == 32 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, extra) == 40 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, win_extra) == 44 );
+C_ASSERT( FIELD_OFFSET(struct create_class_request, client_ptr) == 48 );
+C_ASSERT( sizeof(struct create_class_request) == 56 );
C_ASSERT( FIELD_OFFSET(struct create_class_reply, atom) == 8 );
C_ASSERT( sizeof(struct create_class_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct destroy_class_request, atom) == 12 );
diff --git a/server/trace.c b/server/trace.c
index e2980a3e31..999532a425 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -3753,6 +3753,8 @@ static void dump_create_class_request( const struct create_class_request *req )
{
fprintf( stderr, " local=%d", req->local );
fprintf( stderr, ", atom=%04x", req->atom );
+ fprintf( stderr, ", name_offset=%d", req->name_offset );
+ fprintf( stderr, ", _pad=%d", req->_pad );
fprintf( stderr, ", style=%08x", req->style );
dump_uint64( ", instance=", &req->instance );
fprintf( stderr, ", extra=%d", req->extra );
--
2.17.1
June 11, 2018
Re: [PATCH] winhttp: Store the server certificate context in the request.
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=39055
Your paranoid android.
=== w2003std (32 bit winhttp) ===
winhttp.c:3908: Test failed: got 80072f0d
=== wvistau64_zh_CN (32 bit winhttp) ===
winhttp.c:3104: Test failed: failed to receive response 12152
winhttp.c:3109: Test failed: failed to query status code 12019
winhttp.c:3110: Test failed: request failed unexpectedly 3735928559
June 11, 2018
[PATCH] winhttp: Store the server certificate context in the request.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/winhttp/net.c | 1 -
dlls/winhttp/request.c | 11 +++++++++++
dlls/winhttp/session.c | 14 ++++++--------
dlls/winhttp/tests/winhttp.c | 5 +++++
dlls/winhttp/winhttp_private.h | 2 ++
5 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index d0d02d535e..d577a64783 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -47,7 +47,6 @@
#include "windef.h"
#include "winbase.h"
#include "winhttp.h"
-#include "wincrypt.h"
#include "schannel.h"
#include "winhttp_private.h"
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 96a2c91de5..56ec910294 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -1765,6 +1765,10 @@ static BOOL open_connection( request_t *request )
return FALSE;
}
}
+
+ CertFreeCertificateContext( request->server_cert );
+ request->server_cert = NULL;
+
if (!ensure_cred_handle( connect->session ) ||
!netconn_secure_connect( netconn, connect->hostname, request->security_flags,
&connect->session->cred_handle ))
@@ -1787,6 +1791,13 @@ static BOOL open_connection( request_t *request )
request->netconn = netconn;
}
+ if (netconn->secure && !(request->server_cert = netconn_get_certificate( netconn )))
+ {
+ heap_free( addressW );
+ netconn_close( netconn );
+ return FALSE;
+ }
+
done:
request->read_pos = request->read_size = 0;
request->read_chunked = FALSE;
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index e2b91fa513..fb815682c2 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -40,7 +40,6 @@
#include "winsock2.h"
#include "ws2ipdef.h"
#include "winhttp.h"
-#include "wincrypt.h"
#include "winreg.h"
#define COBJMACROS
#include "ole2.h"
@@ -597,6 +596,8 @@ static void request_destroy( object_header_t *hdr )
}
release_object( &request->connect->hdr );
+ CertFreeCertificateContext( request->server_cert );
+
destroy_authinfo( request->authinfo );
destroy_authinfo( request->proxy_authinfo );
@@ -759,14 +760,14 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
return FALSE;
}
- if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE;
+ if (!(cert = CertDuplicateCertificateContext( request->server_cert ))) return FALSE;
*(CERT_CONTEXT **)buffer = (CERT_CONTEXT *)cert;
*buflen = sizeof(cert);
return TRUE;
}
case WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT:
{
- const CERT_CONTEXT *cert;
+ const CERT_CONTEXT *cert = request->server_cert;
const CRYPT_OID_INFO *oidInfo;
WINHTTP_CERTIFICATE_INFO *ci = buffer;
@@ -778,16 +779,14 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
set_last_error( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
- if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE;
+ if (!cert) return FALSE;
ci->ftExpiry = cert->pCertInfo->NotAfter;
ci->ftStart = cert->pCertInfo->NotBefore;
ci->lpszSubjectInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Subject );
ci->lpszIssuerInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Issuer );
ci->lpszProtocolName = NULL;
- oidInfo = CryptFindOIDInfo( CRYPT_OID_INFO_OID_KEY,
- cert->pCertInfo->SignatureAlgorithm.pszObjId,
- 0 );
+ oidInfo = CryptFindOIDInfo( CRYPT_OID_INFO_OID_KEY, cert->pCertInfo->SignatureAlgorithm.pszObjId, 0 );
if (oidInfo)
ci->lpszSignatureAlgName = (LPWSTR)oidInfo->pwszName;
else
@@ -795,7 +794,6 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
ci->lpszEncryptionAlgName = NULL;
ci->dwKeySize = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0;
- CertFreeCertificateContext( cert );
*buflen = sizeof(*ci);
return TRUE;
}
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 4d8585be1a..2c22276899 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -1107,6 +1107,11 @@ static void test_secure_connection(void)
}
ok(read_size >= available_size, "read_size = %u, available_size = %u\n", read_size, available_size);
+ size = sizeof(cert);
+ ret = WinHttpQueryOption(req, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert, &size);
+ ok(ret, "failed to retrieve certificate context %u\n", GetLastError());
+ if (ret) CertFreeCertificateContext(cert);
+
cleanup:
WinHttpCloseHandle(req);
WinHttpCloseHandle(con);
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 0eb0dead87..d639a2deb2 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -46,6 +46,7 @@
#include "ole2.h"
#include "sspi.h"
+#include "wincrypt.h"
static const WCHAR getW[] = {'G','E','T',0};
static const WCHAR postW[] = {'P','O','S','T',0};
@@ -209,6 +210,7 @@ typedef struct
DWORD optional_len;
netconn_t *netconn;
DWORD security_flags;
+ const CERT_CONTEXT *server_cert;
int resolve_timeout;
int connect_timeout;
int send_timeout;
--
2.11.0
June 11, 2018
Re: [PATCH] webservices/tests: Use the available ARRAY_SIZE() macro
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
June 11, 2018
wine-3.0.2-rc1 Available
by Michael Stefaniuc
Hello guys,
I have pushed wine-3.0.2-rc1 (with tag) to
https://github.com/mstefani/wine-stable/tree/oldstable
http://static-winehq.193b.starter-ca-central-1.openshiftapps.com/stable/
Nothing fancy this time. The bulk of the changes is stuff from wine-3.5
to wine-3.7 with some older stuff that got deferred during 3.0.1.
The interesting parts from the ANNOUNCE file:
What's new in this release (see below for details):
- Various bug fixes
----------------------------------------------------------------
Bugs fixed in 3.0.2 (total 54):
13351 Empire Earth v. 1.00: mouse is not responsive
15350 wrong keyboard layout in Tomb Raider Anniversary / Legend
29842 IE4 crashes on showing certificate authorities, needs
wininet.dll.ParseX509EncodedCertificateForListBoxEntry
29999 Bloodrayne 2: text in the menus misplaced
30076 .NET Framework 4.x with WinVer setting "Windows 7" spams
terminal with "LocaleNameToLCID/LCIDToLocaleName unsupported flags
8000000" (LOCALE_ALLOW_NEUTRAL_NAMES)
30103 Static controls with bitmap do not display correct background.
30611 Lazarus browser sample fails, needs ieframe:ViewObject_Draw
implementation
31850 Age of Mythology needs pidgen.dll.PIDGenSimpA
34101 Need for Speed: Shift demo crashes in 'purist' mode (d3dx9_36)
(needs ID3DXEffect::FindNextValidTechnique method implementation)
36843 "Read only"checkbox on Save As dialog
37228 Cisco Jabber 11.x crashes on unimplemented function
ntdsapi.dll.DsCrackNamesW
37594 World of Warcraft in-game browser does not work (needs
advapi32.BuildSecurityDescriptorW() implementation)
38564 Rush for Berlin Gold crashes after starting
38836 SCM 'StartService' must wait for driver service entry point
execution before return (PunkBuster 'PnkBstrB' service failure, CPU-Z
randomly fails to load its driver, BattlEye 'BEDaisy' kernel service)
39209 Smart Diary Suite 4 crashes when updating options
('CLSID_AudioCompressorCategory',
'{33D9A761-90C8-11d0-BD43-00A0C911CE86}' must be treated as special
category)
39452 mpr.WNetGetUniversalName() return value (causes Intel MPI to fail)
39979 SupArc crashes inside msvcr110
40767 Indiana Jones and The Emperor's Tomb quits after the splash screen
41377 Windows 10 DISM fails to find its resources (kernel32
SetThreadUILanguage must return non-zero/best fit language identifier if
zero is passed)
42267 Rogue-Killer installer crashes on unimplemented function
ntdll.dll._aulldvrm
42446 Native Instruments 'Native Access' 1.1.x fails to start,
reports 'You cannot start Native Access from the mounted disk'
42686 Poedit crashes on start on unimplemented function
msvcp140.dll.?_IsNonBlockingThread(a)_Task_impl_base@details(a)Concurrency@@SA_NXZ
42768 Ys: The Ark of Napishtim (Ys 6) silently crashes playing
in-game videos
43351 x64dbg needs kernel32.dll CreateRemoteThreadEx in Win7+ mode
43831 Cuphead (Steam) crashes on startup (needs
setupapi.CM_Get_Parent stub to return CR_NO_SUCH_DEVNODE)
43930 iCopy 1.6.x (.NET 2.0 app) crashes on startup
(IWiaDevMgr::SelectDeviceDlg DeviceID pointer parameter can be NULL,
needs be declared 'unique' for RPC marshalling)
44135 Olive Tree Bible Software BibleStudySetup_6.0.23.exe fails to
install
44138 Native Access needs unimplemented function
iphlpapi.dll.if_indextoname
44278 Multiple applications crash on unimplemented function
msvcp140.dll.?uncaught_exceptions(a)std@@YAHXZ
44404 Several .Net apps (e.g. Remembear) throw errors/crash,caused by
msctf stubs TextStoreACPSink_{OnTextChange,OnSelectionChange,OnLayoutChange}
44466 PrtSc button crashes StarCraft
44496 Custom imports resolver used by multiple kernel drivers can't
cope with 'ntoskrnl.exe' low-level (wc)string/copy helpers being
forwarded to 'msvcrt.dll' (BattlEye 'BEDaisy', Sentinel HASP 'hardlock.sys')
44504 vlc 2.2.6: playback performance hampered
44530 64-bit Sentinel HASP hardlock.sys kernel driver tries to access
to DR7 (not handled in ntoskrnl emulate_instruction)
44693 Native Access crashes on unimplemented function
vcruntime140.dll.__current_exception
44742 Divinity: Original Sin 2 crashes due to unimplemented
IPHLPAPI.DLL.ConvertLengthToIpv4Mask
44744 Autodesk Fusion 360 need propsys.dll.PSGetPropertyKeyFromName
to be installed
44746 Running any command in MS PowerShell 6+ (.NET app) results in
advapi:EventActivityIdControl console spam
44770 ExpressPCB Plus 1.1 (.NET 3.5 SP1 app) throws
'System.NotImplementedException: Not implemented at
System.Drawing.Pen.TranslateTransform' (GdipTranslatePenTransform not
implemented)
44772 progecad 2018 installer does not start
44804 PCBWeb crashes: Call to unimplemented function
d3dx11_43.dll.D3DX11CreateTextureFromFileW
44811 BattlEye 'BEDaisy' kernel service crashes on unimplemented
function ntoskrnl.exe._chkstk
44818 ntdll.NtClose (kernel32.CloseHandle) should throw invalid
handle exception (EXCEPTION_INVALID_HANDLE) for invalid handles when run
under debugger
44864 Incoming crashes after the intro video
44874 Phonetools 9.x crashes on unimplemented function
KERNEL32.dll.RequestDeviceWakeup
44904 winebus blocks auto start up of scheduler service
44923 Failing kernel driver services can stall WINEPREFIX
bootstrapping/startup for a considerable time when configured as autostart
44924 StarForce v3 kernel drivers need
ntoskrnl.IoCreateSynchronizationEvent to return a non-NULL handle
44932 limited list of available printer's paper/page size
44944 Adobe Premiere Elements 14 fails to install: ERROR: Third party
payload installer pxengine5_08_13a.exe failed with exit code: -1
44971 HackShield for Banking Driver 'HSBDrvNt.sys' (part of Ahnlab
Safe Transaction) crashes on unimplemented function
ntoskrnl.exe.ExInterlockedPopEntrySList
44984 Maya 2018 LT Installer requires unimplemented function
api-ms-win-crt-time-l1-1-0.dll._timespec64_get
44993 Magic The Gathering Arena fails to install
45026 Windows File Manager (WinFile) fails to build in winelib
(LPDROPSTRUCT missing from winuser.h)
----------------------------------------------------------------
Changes since 3.0.1:
Alexander Morozov (1):
ntoskrnl.exe: Add stubs for ExAcquireFastMutexUnsafe and
ExReleaseFastMutexUnsafe.
Alexandre Julliard (7):
winex11: Use the correct colormap for the OpenGL parent window.
winex11: Store the visual info in the OpenGL pixel format.
winex11: Store only the pixmap size instead of the window
rectangle in the GL drawable.
winex11: Implement refcounting of GL drawables.
winex11: Hold a reference to the drawable from the GL context.
wininet/tests: Update the winehq.org certificate data.
ntoskrnl: Add emulation of CRn and DRn registers on x86-64.
Alistair Leslie-Hughes (9):
comctl32/treeview: Fix item icon background when using
TVS_FULLROWSELECT style.
pidgen: Add PIDGenSimpA stub.
winedevice: Wait until driver has started before returning.
ntoskrnl.exe: Dont forward some msvcrt functions.
propsys: Add PSGetPropertyKeyFromName stub.
ntoskrnl.exe: Implement _chkstk.
winedevice: Improve error handling when a driver fails to load.
maintainers: Update Staging branch.
maintainers: Remove previous wine-staging maintainers.
Andrew Eikum (1):
maintainers: Remove myself from a dmusic DLL.
Andrew Wesie (1):
advapi32: Implement BuildSecurityDescriptorW.
Andrey Gusev (1):
d3dx11: Add D3DX11CreateTextureFromFileA/W stub.
André Hentschel (3):
wininet: Fix negated check for drain_content result (clang).
gdiplus: Add stub for GdipSetPathGradientPath.
progman: Fix warning in PUT_SHORT macro (clang).
Austin English (4):
wininet: Add ParseX509EncodedCertificateForListBoxEntry stub.
ntdsapi: Add DsCrackNamesA/W stubs.
include/winuser.h: Add tagDROPSTRUCT struct.
include/wfext.h: Add miscellaneous FM_* defines.
Christian Inci (1):
wined3d: Recognize Titan V.
Dagfinn Reiakvam (1):
iphlpapi: Add support for ConvertLengthToIpv4Mask().
Dmitry Timoshkov (5):
avifil32: Correct threading model on interfaces.
services: Add a 3000 ms timeout to StartService.
winspool.drv: Add A0, A1 and A2 paper sizes to generic.ppd.
dinput: The DIK_ key code should match the scan code.
sspicli: Add forwards to secur32.
Gijs Vermeulen (1):
ntoskrnl.exe: Improve IoCreateSynchronizationEvent stub.
Hans Leidekker (2):
iphlpapi: Implement if_indextoname.
msi: Don't cache the base URL.
Henri Verbeet (1):
winex11: Restore the X11DRV_FLUSH_GL_DRAWABLE XFlush() for setups
without OML_sync_control.
Huw D. M. Davies (1):
winebuild: On x86_64, save xmm0 - 3 during the delayed import lookup.
Ivan Kalvachev (1):
kernel32: Add DECL_HOTPATCH to OutputDebugString functions.
Jarkko Korpi (1):
kernel32: Silence repeated LocaleNameToLCID unsupported flags.
Johann Frei (1):
dinput: Implement X/Y axis granularity and add test.
Louis Lenders (9):
ntdll: Update version resource.
kernel32/tests: Add simple test for SetThreadUILanguage.
kernel32: Improve stub for SetThreadUILanguage.
iexplore/iexplore.inf: Add svcVersion reg key and update to win7.
msctf: Return S_OK in TextStoreACPSink_OnTextChange.
msctf: Return S_OK in TextStoreACPSink_OnSelectionChange.
msctf: Return S_OK in TextStoreACPSink_OnLayoutChange.
wine.inf: Create catroot directory.
kernel32: Add stub for RequestDeviceWakeup.
Mark White (1):
kernel32: Fix forward slash path handling to GetVolumePathNameW.
Martin Storsjo (1):
ucrtbase: Hook up __intrinsic_setjmpex for x86_64 and arm64.
Matteo Bruni (2):
d3dx9: Implement FindNextValidTechnique().
d3d8: Forbid setting a viewport larger than the render target.
Michael Müller (3):
ieframe: Return S_OK in IViewObject::Draw stub.
mpr: Return correct error code for non network paths and
REMOTE_NAME_INFO_LEVEL in WNetGetUniversalName.
ntoskrnl: Implement ExInterlockedPopEntrySList.
Michael Stefaniuc (1):
maintainers: Add a DirectMusic section.
Nikolay Sivov (7):
comdlg32: Add a helper to test if file dialog hook is enabled.
comdlg32: Hide Read-only checkbox for Save dialogs.
gdiplus: Implement GdipTranslatePenTransform.
wincodecs: Use static array for property bag descriptions.
wincodecs: Encoder options are optional for CreateNewFrame().
user32/static: Use correct brush color for centered image background.
kernel32: Add CreateRemoteThreadEx().
Piotr Caban (6):
msvcrt: Optimize _strupr implementation in C locale.
msvcrt/tests: Add _strupr tests.
msvcp140: Add __uncaught_exceptions implementation.
ucrtbase: Add __current_exception() implementation.
msvcp140: Add _Task_impl_base::_IsNonBlockingThread stub.
ucrtbase: Add _timespec{32,64}_get implementation.
Sebastian Lackner (2):
ntdll: Throw exception if invalid handle is passed to NtClose and
debugger enabled.
advapi32/tests: Add basic tests for BuildSecurityDescriptor.
Stefan Dösinger (1):
ddraw: Don't read past the end of the executebuffer.
Stefan Leichter (2):
advapi32: Silence the fixme in EventActivityIdControl.
include: Fix declaration of SelectDeviceDlg.
Tim Wanders (1):
setupapi: Return CR_NO_SUCH_DEVNODE from CM_Get_Parent stub.
Zebediah Figura (5):
ntdll: Implement _alldvrm() and _aulldvrm().
devenum/tests: Test registering DirectShow filters.
devenum: More correctly handle device types.
devenum: Allow parsing display name without class ID.
devenum: Correctly implement IMoniker::GetDisplayName().
--
Michael Stefaniuc
mstefani(a)winehq.org
June 10, 2018
[PATCH] find: First simple implementation and tests
by Fabian Maurer
The message text is the same as on windows,
since the exit code doesn't seem reliable.
Currently only supports single line searching,
and not unicode aware. I'll add tests and if needed an implementation
for that sometime later.
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
configure | 25 ++----
configure.ac | 1 +
programs/find/Makefile.in | 5 +-
programs/find/find.c | 112 +++++++++++++++++++++--
programs/find/resources.h | 27 ++++++
programs/find/rsrc.rc | 25 ++++++
programs/find/tests/Makefile.in | 4 +
programs/find/tests/find.c | 151 ++++++++++++++++++++++++++++++++
8 files changed, 326 insertions(+), 24 deletions(-)
create mode 100644 programs/find/resources.h
create mode 100644 programs/find/rsrc.rc
create mode 100644 programs/find/tests/Makefile.in
create mode 100644 programs/find/tests/find.c
diff --git a/configure b/configure
index 299fb407d8..56e7dde04c 100755
--- a/configure
+++ b/configure
@@ -800,7 +800,6 @@ infodir
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1862,7 +1861,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -2115,15 +2113,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -2261,7 +2250,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -2414,7 +2403,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -6626,7 +6614,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -6672,7 +6660,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -6696,7 +6684,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -6741,7 +6729,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -6765,7 +6753,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -19379,6 +19367,7 @@ wine_fn_config_makefile programs/explorer enable_explorer
wine_fn_config_makefile programs/extrac32 enable_extrac32
wine_fn_config_makefile programs/fc enable_fc
wine_fn_config_makefile programs/find enable_find
+wine_fn_config_makefile programs/find/tests enable_tests
wine_fn_config_makefile programs/findstr enable_findstr
wine_fn_config_makefile programs/fsutil enable_fsutil
wine_fn_config_makefile programs/hh enable_hh
diff --git a/configure.ac b/configure.ac
index 469fa8d729..1d6a4cf1c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3878,6 +3878,7 @@ WINE_CONFIG_MAKEFILE(programs/explorer)
WINE_CONFIG_MAKEFILE(programs/extrac32)
WINE_CONFIG_MAKEFILE(programs/fc)
WINE_CONFIG_MAKEFILE(programs/find)
+WINE_CONFIG_MAKEFILE(programs/find/tests)
WINE_CONFIG_MAKEFILE(programs/findstr)
WINE_CONFIG_MAKEFILE(programs/fsutil)
WINE_CONFIG_MAKEFILE(programs/hh)
diff --git a/programs/find/Makefile.in b/programs/find/Makefile.in
index ef8d61b7ce..4a90905986 100644
--- a/programs/find/Makefile.in
+++ b/programs/find/Makefile.in
@@ -1,4 +1,7 @@
MODULE = find.exe
-APPMODE = -mconsole -municode
+APPMODE = -mconsole
+IMPORTS = user32 shlwapi
C_SRCS = find.c
+
+RC_SRCS = rsrc.rc
diff --git a/programs/find/find.c b/programs/find/find.c
index 9d7aecd402..937f773243 100644
--- a/programs/find/find.c
+++ b/programs/find/find.c
@@ -16,18 +16,120 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <windows.h>
+#include <stdlib.h>
+#include <shlwapi.h>
+
+#include "wine/heap.h"
#include "wine/debug.h"
+#include "resources.h"
WINE_DEFAULT_DEBUG_CHANNEL(find);
-int wmain(int argc, WCHAR *argv[])
+char* read_from_pipe(HANDLE handle)
+{
+ char buffer[4096];
+ DWORD bytes_read;
+ DWORD length = 0;
+ BOOL success;
+ char *ret = heap_alloc_zero(1);
+
+ for (;;)
+ {
+ success = ReadFile(handle, buffer, sizeof(buffer), &bytes_read, NULL);
+ if (!success || !bytes_read)
+ break;
+ ret = heap_realloc(ret, length + bytes_read);
+ memcpy((char *)ret + length, buffer, bytes_read);
+ length += bytes_read;
+ }
+
+ ret[length] = 0;
+ return ret;
+}
+
+void write_to_pipe(HANDLE handle, const char *str)
+{
+ DWORD bytes_written_sum = 0;
+ DWORD length = lstrlenA(str);
+ do
+ {
+ DWORD bytes_written;
+ WriteFile(handle, str, length * sizeof(char), &bytes_written, NULL);
+ bytes_written_sum += bytes_written;
+ } while (bytes_written_sum < length);
+}
+
+void find_printf(const char *str)
+{
+ write_to_pipe(GetStdHandle(STD_OUTPUT_HANDLE), str);
+}
+
+int do_find(const char *text, const char* tofind)
{
+ void *found;
+
+ if (lstrlenA(text) == 0)
+ return 1;
+
+ found = StrStrA(text, tofind);
+
+ if (found)
+ {
+ find_printf(text);
+ find_printf("\r\n");
+ return 0;
+ }
+
+ return 1;
+}
+
+int main(int argc, char *argv[])
+{
+ char *text_stdin;
+ char *tofind = NULL;
+ char message_parameter_invalid[64];
+ char message_switch_invalid[64];
int i;
+ int exitcode;
- WINE_FIXME("stub:");
+ TRACE("running find:");
for (i = 0; i < argc; i++)
- WINE_FIXME(" %s", wine_dbgstr_w(argv[i]));
- WINE_FIXME("\n");
+ {
+ TRACE(" %s", argv[i]);
+ }
+ TRACE("\n");
+
+ LoadStringA(GetModuleHandleW(NULL), IDS_INVALID_PARAMETER, message_parameter_invalid, sizeof(message_parameter_invalid));
+ LoadStringA(GetModuleHandleW(NULL), IDS_INVALID_SWITCH, message_switch_invalid, sizeof(message_switch_invalid));
+
+ /* We read the complete input at once, for simplicity */
+ text_stdin = read_from_pipe(GetStdHandle(STD_INPUT_HANDLE));
+
+ for (i = 1; i < argc; i++)
+ {
+ if (argv[i][0] == '/')
+ {
+ find_printf(message_switch_invalid);
+ exitcode = 2;
+ goto cleanup;
+ }
+ else if(tofind == NULL)
+ {
+ tofind = argv[i];
+ }
+ }
+
+ if (tofind == NULL)
+ {
+ find_printf(message_parameter_invalid);
+ exitcode = 2;
+ goto cleanup;
+ }
+
+ exitcode = do_find(text_stdin, tofind);
- return 0;
+cleanup:
+ heap_free(text_stdin);
+ return exitcode;
}
diff --git a/programs/find/resources.h b/programs/find/resources.h
new file mode 100644
index 0000000000..8712d91e36
--- /dev/null
+++ b/programs/find/resources.h
@@ -0,0 +1,27 @@
+/*
+ * Resource IDs
+ *
+ * Copyright 2018 Fabian Maurer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_FIND_RESOURCES_H
+#define __WINE_FIND_RESOURCES_H
+
+#define IDS_INVALID_PARAMETER 1000
+#define IDS_INVALID_SWITCH 1001
+
+#endif /* __WINE_FIND_RESOURCES_H */
diff --git a/programs/find/rsrc.rc b/programs/find/rsrc.rc
new file mode 100644
index 0000000000..f10fb6285f
--- /dev/null
+++ b/programs/find/rsrc.rc
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2018 Fabian Maurer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "resources.h"
+
+STRINGTABLE
+{
+ IDS_INVALID_PARAMETER "FIND: Parameter format not correct\r\n"
+ IDS_INVALID_SWITCH "FIND: Invalid switch\r\n"
+}
diff --git a/programs/find/tests/Makefile.in b/programs/find/tests/Makefile.in
new file mode 100644
index 0000000000..ad88243ede
--- /dev/null
+++ b/programs/find/tests/Makefile.in
@@ -0,0 +1,4 @@
+TESTDLL = find.exe
+
+C_SRCS = \
+ find.c
diff --git a/programs/find/tests/find.c b/programs/find/tests/find.c
new file mode 100644
index 0000000000..2dce343965
--- /dev/null
+++ b/programs/find/tests/find.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2018 Fabian Maurer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "wine/heap.h"
+#include "wine/test.h"
+
+/* Copied from find.exe implementation */
+char* read_from_pipe(HANDLE handle)
+{
+ char buffer[4096];
+ DWORD bytes_read;
+ DWORD length = 0;
+ BOOL success;
+ char *ret = heap_alloc_zero(1);
+
+ for (;;)
+ {
+ success = ReadFile(handle, buffer, sizeof(buffer), &bytes_read, NULL);
+ if (!success || !bytes_read)
+ break;
+ ret = heap_realloc(ret, length + bytes_read);
+ memcpy((char *)ret + length, buffer, bytes_read);
+ length += bytes_read;
+ }
+
+ ret[length] = 0;
+ return ret;
+}
+
+/* Copied from find.exe implementation */
+void write_to_pipe(HANDLE handle, const char *str)
+{
+ DWORD bytes_written_sum = 0;
+ DWORD length = lstrlenA(str);
+ do
+ {
+ DWORD bytes_written;
+ WriteFile(handle, str, length * sizeof(char), &bytes_written, NULL);
+ bytes_written_sum += bytes_written;
+ } while (bytes_written_sum < length);
+}
+
+#define run_find(commandline, input, out_expected, exitcode_expected) \
+ run_find_(commandline, input, out_expected, exitcode_expected, __FILE__, __LINE__)
+
+static void run_find_(const char *commandline, const char *input, const char *out_expected, int exitcode_expected, const char *file, int line)
+{
+ HANDLE child_stdin_read;
+ HANDLE child_stdout_write;
+ HANDLE parent_stdin_write;
+ HANDLE parent_stdout_read;
+ STARTUPINFOA startup_info = {0};
+ SECURITY_ATTRIBUTES security_attributes;
+ PROCESS_INFORMATION process_info = {0};
+ char *child_output = NULL;
+ char cmd[4096];
+ int comparison;
+ DWORD exitcode;
+
+ security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
+ security_attributes.bInheritHandle = TRUE;
+ security_attributes.lpSecurityDescriptor = NULL;
+
+ CreatePipe(&parent_stdout_read, &child_stdout_write, &security_attributes, 0);
+ CreatePipe(&child_stdin_read, &parent_stdin_write, &security_attributes, 0);
+
+ SetHandleInformation(parent_stdout_read, HANDLE_FLAG_INHERIT, 0);
+ SetHandleInformation(parent_stdin_write, HANDLE_FLAG_INHERIT, 0);
+
+ startup_info.cb = sizeof(STARTUPINFOW);
+ startup_info.hStdInput = child_stdin_read;
+ startup_info.hStdOutput = child_stdout_write;
+ startup_info.hStdError = NULL;
+ startup_info.dwFlags |= STARTF_USESTDHANDLES;
+
+ sprintf(cmd, "find.exe %s", commandline);
+ CreateProcessA(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startup_info, &process_info);
+ CloseHandle(child_stdin_read);
+ CloseHandle(child_stdout_write);
+
+ write_to_pipe(parent_stdin_write, input);
+ CloseHandle(parent_stdin_write);
+
+ child_output = read_from_pipe(parent_stdout_read);
+ CloseHandle(parent_stdout_read);
+
+ GetExitCodeProcess(process_info.hProcess, &exitcode);
+ CloseHandle(process_info.hProcess);
+ CloseHandle(process_info.hThread);
+
+ comparison = lstrcmpA(child_output, out_expected);
+
+ ok_(file, line)(comparison == 0, "\n#################### Expected:\n"
+ "%s\n"
+ "#################### But got:\n"
+ "%s\n"
+ "####################\n",
+ out_expected, child_output);
+ ok_(file, line)(exitcode == exitcode_expected, "Expected exitcode %d, got %d\n", exitcode_expected, exitcode);
+
+ heap_free(child_output);
+}
+
+static void test_errors(void)
+{
+ run_find("", "", "FIND: Parameter format not correct\r\n", 2);
+ todo_wine
+ run_find("test", "", "FIND: Parameter format not correct\r\n", 2);
+ todo_wine
+ run_find("\"test", "", "FIND: Parameter format not correct\r\n", 2);
+ run_find("\"test\" /XYZ", "", "FIND: Invalid switch\r\n", 2);
+}
+
+static void test_singleline_without_switches(void)
+{
+ run_find("\"\"", "test", "", 1);
+ run_find("\"test\"", "", "", 1);
+ run_find("\"test\"", "test", "test\r\n", 0);
+ run_find("\"test\"", "test2", "test2\r\n", 0);
+ run_find("\"test2\"", "test", "", 1);
+}
+
+START_TEST(find)
+{
+ if (PRIMARYLANGID(GetUserDefaultUILanguage()) != LANG_ENGLISH)
+ {
+ skip("Tests only work with english locale.\n");
+ return;
+ }
+
+ test_errors();
+ test_singleline_without_switches();
+}
--
2.17.1
June 10, 2018
[PATCH] po: Update Norwegian translation.
by Kim Malmo
Signed-off-by: Kim Malmo <berencamlost(a)msn.com>
---
po/nb_NO.po | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/po/nb_NO.po b/po/nb_NO.po
index 2021f0d18a..d6999c1043 100644
--- a/po/nb_NO.po
+++ b/po/nb_NO.po
@@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: Wine\n"
"Report-Msgid-Bugs-To: https://bugs.winehq.org\n"
"POT-Creation-Date: N/A\n"
-"PO-Revision-Date: 2018-05-18 13:47+0200\n"
+"PO-Revision-Date: 2018-06-09 23:18+0200\n"
"Last-Translator: Kim Malmo <berencamlost(a)msn.com>\n"
"Language-Team: Norwegian Bokmål <alexsornes(a)gmail.com>\n"
"Language: nb_NO\n"
@@ -12800,10 +12800,8 @@ msgid "Confirm Value Delete"
msgstr "Bekreft sletting av verdi"
#: regedit.rc:210
-#, fuzzy
-#| msgid "Are you sure you want to delete the registry value '%1'?"
msgid "Are you sure you want to delete the selected registry value?"
-msgstr "Virkelig slette registerverdien \"%1\"?"
+msgstr "Virkelig slette den valgte registerverdien?"
#: regedit.rc:216
msgid "Search complete. The string '%1' was not found."
--
2.17.1
June 9, 2018
Re: [PATCH v2] shellpath.c: Fix creation of HOME directory symbolic links
by Bob Wya
On 8 June 2018 at 12:52, Huw Davies <huw(a)codeweavers.com> wrote:
> On Fri, Jun 08, 2018 at 10:58:23AM +0100, Rob Walker wrote:
> > Fixes: https://bugs.winehq.org/show_bug.cgi?id=41668
> >
> > The Shell Folders, that Wine symlinks to the user's HOME directory, are
> > only re-created on each Wine boot if they: do not pre-exist or are broken
> > symbolic links.
> >
> > Handling the DESKTOP Shell Folder is a special case as this is created
> twice
> > (during a standard boot), early in the Wine boot process. This is
> handled by
> > 2 separate processes, loading shell32.dll, in sequence. This makes it
> hard to determine
> > if the DESKTOP folder was created before the Wine boot (either from a
> previous Wine boot
> > or by the end user).
> >
> > The final (implemented) solution determines the exact start time of the
> Wine boot process
> > (using the current system time and tick-count). If the DESKTOP directory
> was last written
> > after this Wine boot time, we can assume that "we" (Wine) automatically
> created the
> > directory. Only in this instance do we attempt to set a symlink to the
> DESKTOP directory
> > (subdirectory of HOME).
>
> There's still too much going on here.
>
> Do you really need to refactor the code to make your change?
> If not, then just send in the change to the current code.
> If you need to refactor, then do the refactoring first
> (I could imagine taking 3-4 patches to do the refactoring[1])
> then make the change as a final patch in the series.
>
> The file-time / boot-time thing seems hacky, I'm not exactly
> sure what you're trying do to, but this doesn't sound right.
> Hopefully that will become clearer as you tidy things up.
>
> Huw.
>
> [1] For example move the creation of My Pictures/My Videos/etc
> first, then move My Documents and finally Desktop. These
> final two are special cases in the current code, we'd need
> to see that in any new code.
>
Sorry I forgot to update the commit message! I'd updated the code (in the
v2 patch), for handling the
special case of the User profile Desktop directory, without testing file
times / boot times (the latter
didn't work as GetTickTime64 was returning the host system uptime anyway).
--------------------------------------------------------------------------------------------------------------------------------
I have a number of concerns with the existing implementation of
_SHCreateSymbolicLinks():
1) The function is far too long, in it's present form - it's currently 165
lines long!
2) The comments should be far more terse and precise.
3) Using infinite while (1) loops to de-mark code blocks only serves to
obscure the functionality of the code.
4)
4487- /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos'
and 'My Music' subdirs
4488- * in '%USERPROFILE%\\My Documents' or fail silently if they
already exist. */
4489- pszHome = NULL;
4490- strcpy(szPersonalTarget, pszPersonal);
4491- for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) {
4492- strcpy(szMyStuffTarget, szPersonalTarget);
4493- if (_SHAppendToUnixPath(szMyStuffTarget,
MAKEINTRESOURCEW(aidsMyStuff[i])))
4494- mkdir(szMyStuffTarget, 0777);
4495- }
Windows Vista (and newer) do not nest the User profile directories. Since
Wine is targeting Windows 7 by default - this
legacy behaviour should be removed. (As an end user, who used to use
Windows XP, this was simply an annoying default
layout anyway.)
5)
4447- /* '$HOME/My Documents' exists. Create 'My Pictures',
4448- * 'My Videos' and 'My Music' subfolders or fail
silently if
4449- * they already exist.
4450- */
4451- for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++)
4452- {
4453- strcpy(szMyStuffTarget, szPersonalTarget);
4454- if (_SHAppendToUnixPath(szMyStuffTarget,
MAKEINTRESOURCEW(aidsMyStuff[i])))
4455- mkdir(szMyStuffTarget, 0777);
4456- }
4457- break;
Ditto as per (4). This is an obsolete User Profile directory layout
(pre-Vista).
Also if "${HOME}/My Documents" exists then this block of code will start
creating subdirectories in this
folder. I don't think that Wine should be making the rather arbitrary
assumption that a Wine user wants
their "${HOME}" directory spammed with new subdirectories.
I often read online, comments from Wine users, complaining about this sort
of behaviour...
6)
4543- /* Last but not least, the Desktop folder */
4544- if (pszHome)
4545- strcpy(szDesktopTarget, pszHome);
4546- else
4547- strcpy(szDesktopTarget, pszPersonal);
4548- heap_free(pszPersonal);
4549-
4550- xdg_desktop_dir = xdg_results ? xdg_results[num - 1] : NULL;
4551- if (xdg_desktop_dir ||
4552- (_SHAppendToUnixPath(szDesktopTarget, DesktopW) &&
4553- !stat(szDesktopTarget, &statFolder) &&
S_ISDIR(statFolder.st_mode)))
4554- {
4555- hr = SHGetFolderPathW(NULL,
CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE,
NULL,
4556- SHGFP_TYPE_DEFAULT, wszTempPath);
4557- if (SUCCEEDED(hr) && (pszDesktop =
wine_get_unix_file_name(wszTempPath)))
4558- {
4559- remove(pszDesktop);
4560- if (xdg_desktop_dir)
4561- symlink(xdg_desktop_dir, pszDesktop);
4562- else
4563- symlink(szDesktopTarget, pszDesktop);
4564- heap_free(pszDesktop);
4565- }
4566- }
This code uses pszPersonal as a fallback target for when HOME is unset.
This will be the equivalent of:
"${WINEPREFIX}/dosdevices/c:/users/${USER}/My Documents"
Say the XDG_DESKTOP_DIR check fails. Then Wine tries to find the directory:
"${WINEPREFIX}/dosdevices/c:/users/${USER}/My Documents/Desktop"
as a symlink target. Which never succeeds because Wine never creates this
directory...
This extra path appears to be redundant (HOME unset / XDG_DESKTOP_DIR
unset).
--------------------------------------------------------------------------------------------------------------------------------
I can of course leave the variable names unchanged and the function name.
I was "told off" for not using snake case on a previous Wine commit - so I
assumed
I had to follow this standard if I wanted to refactor existing code. :-)
I'd like to tidy this function up and make it more readable (including the
comments).
Which I can do in staged patches, as you suggested.
But obviously I'd like to feel that we are both on the "same page" about
the changes
I discussed (above). Before I email in a v3 staged patchset.
June 8, 2018
Re: [PATCH] d3dcompiler/tests: Use the available ARRAY_SIZE() macro
by Matteo Bruni
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
June 8, 2018
[PATCH] ntprint/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/ntprint/tests/ntprint.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/ntprint/tests/ntprint.c b/dlls/ntprint/tests/ntprint.c
index 1710220def..57caa49ab2 100644
--- a/dlls/ntprint/tests/ntprint.c
+++ b/dlls/ntprint/tests/ntprint.c
@@ -67,7 +67,7 @@ static void test_PSetupCreateMonitorInfo(VOID)
{
HANDLE mi;
WCHAR buffer[1024] = {'\\','\\'};
- UINT len = sizeof(buffer) / sizeof(buffer[0]) - 2;
+ UINT len = ARRAY_SIZE(buffer) - 2;
GetComputerNameW(buffer + 2, &len);
SetLastError(0xdeadbeef);
@@ -155,7 +155,7 @@ static void test_PSetupEnumMonitor(VOID)
"and '> 0')\n", res, GetLastError(), minsize);
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
if ((minsize + 1) > size) {
skip("overflow: %u\n", minsize);
pPSetupDestroyMonitorInfo(mi);
@@ -165,7 +165,7 @@ static void test_PSetupEnumMonitor(VOID)
if (0) {
/* XP: ERROR_INVALID_PARAMETER, w2k: Crash */
SetLastError(0xdeadbeef);
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
res = pPSetupEnumMonitor(NULL, 0, buffer, &size);
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
@@ -175,7 +175,7 @@ static void test_PSetupEnumMonitor(VOID)
if (0) {
/* XP: Crash, w2k: Success (how can that work?) */
SetLastError(0xdeadbeef);
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
res = pPSetupEnumMonitor(mi, 0, NULL, &size);
trace("got %u with %u and %u\n", res, GetLastError(), size);
}
@@ -213,7 +213,7 @@ static void test_PSetupEnumMonitor(VOID)
while (res && (index < 20)) {
SetLastError(0xdeadbeef);
buffer[0] = '\0';
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
res = pPSetupEnumMonitor(mi, index, buffer, &size);
ok( res || (GetLastError() == ERROR_NO_MORE_ITEMS),
"(%u) got %u with %u and %u (expected '!=0' or: '0' with "
--
2.14.4
June 8, 2018
[PATCH] oleacc/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleacc/tests/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c
index 7a0737caff..c62fa79556 100644
--- a/dlls/oleacc/tests/main.c
+++ b/dlls/oleacc/tests/main.c
@@ -410,7 +410,7 @@ static void test_getroletext(void)
memset(buff2W, 0, sizeof(buff2W));
ret = GetRoleTextW(role, NULL, 0);
- GetRoleTextW(role, buff2W, sizeof(buff2W)/sizeof(WCHAR));
+ GetRoleTextW(role, buff2W, ARRAY_SIZE(buff2W));
ok(ret == lstrlenW(buff2W),
"GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role);
}
--
2.14.4
June 8, 2018
[PATCH] psapi/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/psapi/tests/psapi_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index 4adc82619b..0ff212c766 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -536,12 +536,12 @@ todo_wine {
}
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW, sizeof(map_nameW)/sizeof(map_nameW[0]));
+ ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW, ARRAY_SIZE(map_nameW));
todo_wine {
ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
ok(ret > strlen(device_name), "map_name should be longer than device_name\n");
}
- if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name, sizeof(nt_map_name)/sizeof(nt_map_name[0])))
+ if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name, ARRAY_SIZE(nt_map_name)))
{
ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name);
WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL);
@@ -658,7 +658,7 @@ static void test_GetProcessImageFileName(void)
/* correct call */
memset(szImgPathW, 0xff, sizeof(szImgPathW));
- ret = pGetProcessImageFileNameW(hpQI, szImgPathW, sizeof(szImgPathW)/sizeof(WCHAR));
+ ret = pGetProcessImageFileNameW(hpQI, szImgPathW, ARRAY_SIZE(szImgPathW));
ok(ret > 0, "GetProcessImageFileNameW should have succeeded.\n");
ok(szImgPathW[0] == '\\', "GetProcessImageFileNameW should have returned an NT path.\n");
ok(lstrlenW(szImgPathW) == ret, "Expected length to be %d, got %d\n", ret, lstrlenW(szImgPathW));
--
2.14.4
June 8, 2018
[PATCH] quartz/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/quartz/tests/avisplitter.c | 4 ++--
dlls/quartz/tests/filtergraph.c | 6 +++---
dlls/quartz/tests/misc.c | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/quartz/tests/avisplitter.c b/dlls/quartz/tests/avisplitter.c
index 8bafb14157..bc933d148d 100644
--- a/dlls/quartz/tests/avisplitter.c
+++ b/dlls/quartz/tests/avisplitter.c
@@ -210,7 +210,7 @@ static void test_filesourcefilter(void)
ret = GetTempFileNameW(temp, prefix, 0, path);
ok(ret, "GetTempFileNameW failed with error %u\n", GetLastError());
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
trace("Running test for %s\n", tests[i].label);
@@ -280,7 +280,7 @@ static WCHAR *load_resource(const WCHAR *name)
HRSRC res;
void *ptr;
- GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
lstrcatW(pathW, name);
file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index a1ece9489f..85079d982d 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -50,7 +50,7 @@ static WCHAR *load_resource(const WCHAR *name)
HRSRC res;
void *ptr;
- GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
lstrcatW(pathW, name);
file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
@@ -1500,14 +1500,14 @@ static HRESULT createtestfilter(const CLSID* pClsid, const TestFilterPinData *pi
pinInfo.pFilter = &pTestFilter->IBaseFilter_iface;
if (pinInfo.dir == PINDIR_INPUT)
{
- lstrcpynW(pinInfo.achName, wcsInputPinName, sizeof(pinInfo.achName) / sizeof(pinInfo.achName[0]));
+ lstrcpynW(pinInfo.achName, wcsInputPinName, ARRAY_SIZE(pinInfo.achName));
hr = TestFilter_Pin_Construct(&TestFilter_InputPin_Vtbl, &pinInfo, &mt, &pTestFilter->csFilter,
&pTestFilter->ppPins[i]);
}
else
{
- lstrcpynW(pinInfo.achName, wcsOutputPinName, sizeof(pinInfo.achName) / sizeof(pinInfo.achName[0]));
+ lstrcpynW(pinInfo.achName, wcsOutputPinName, ARRAY_SIZE(pinInfo.achName));
hr = TestFilter_Pin_Construct(&TestFilter_OutputPin_Vtbl, &pinInfo, &mt, &pTestFilter->csFilter,
&pTestFilter->ppPins[i]);
}
diff --git a/dlls/quartz/tests/misc.c b/dlls/quartz/tests/misc.c
index 748c0f2cfd..16b6d40ce4 100644
--- a/dlls/quartz/tests/misc.c
+++ b/dlls/quartz/tests/misc.c
@@ -169,7 +169,7 @@ static void test_null_renderer_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_NullRenderer, IID_IReferenceClock, *iids[i]);
}
@@ -182,7 +182,7 @@ static void test_video_renderer_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_VideoRenderer,
IID_IReferenceClock, *iids[i]);
@@ -199,7 +199,7 @@ static void test_filter_graph_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_FilterGraph,
IID_IReferenceClock, *iids[i]);
@@ -213,7 +213,7 @@ static void test_filter_mapper_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_FilterMapper2,
IID_IReferenceClock, *iids[i]);
--
2.14.4
June 8, 2018
[PATCH] rpcrt4/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/rpcrt4/tests/cstub.c | 2 +-
dlls/rpcrt4/tests/rpc.c | 6 ++----
dlls/rpcrt4/tests/server.c | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/rpcrt4/tests/cstub.c b/dlls/rpcrt4/tests/cstub.c
index 606107fcfd..7bed308807 100644
--- a/dlls/rpcrt4/tests/cstub.c
+++ b/dlls/rpcrt4/tests/cstub.c
@@ -596,7 +596,7 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
#undef VTBL_PROXY_TEST
#undef VTBL_PROXY_TEST_NOT_ZERO
- for (i = 0; i < sizeof(interfaces)/sizeof(interfaces[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(interfaces); i++)
ok( proxy_vtbl[i]->header.piid == interfaces[i],
"wrong proxy %u iid %p/%p\n", i, proxy_vtbl[i]->header.piid, interfaces[i] );
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index f026e99de2..c9f2a4b721 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -149,10 +149,8 @@ static void TestDceErrorInqText (void)
*/
DWORD dwCount;
- dwCount = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, RPC_S_NOT_RPC_ERROR, 0, bufferInvalid,
- sizeof(bufferInvalid)/sizeof(bufferInvalid[0]), NULL);
+ dwCount = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+ RPC_S_NOT_RPC_ERROR, 0, bufferInvalid, ARRAY_SIZE(bufferInvalid), NULL);
/* A random sample of DceErrorInqText */
/* 0 is success */
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index dfad1ed0f3..b35b71bcfd 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -313,7 +313,7 @@ void __cdecl s_get_number_array(int x[20], int *n)
{
int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
memcpy(x, c, sizeof(c));
- *n = sizeof(c)/sizeof(c[0]);
+ *n = ARRAY_SIZE(c);
}
int __cdecl s_sum_cs(cs_t *cs)
--
2.14.4
June 8, 2018
[PATCH] webservices/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/webservices/tests/channel.c | 12 ++++++------
dlls/webservices/tests/msg.c | 2 +-
dlls/webservices/tests/proxy.c | 8 ++++----
dlls/webservices/tests/reader.c | 20 ++++++++++----------
dlls/webservices/tests/url.c | 4 ++--
dlls/webservices/tests/writer.c | 38 +++++++++++++++++++-------------------
6 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c
index 17a0b58ac8..c995a08829 100644
--- a/dlls/webservices/tests/channel.c
+++ b/dlls/webservices/tests/channel.c
@@ -134,7 +134,7 @@ static void test_WsOpenChannel(void)
ok( hr == E_INVALIDARG, "got %08x\n", hr );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenChannel( NULL, &addr, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
@@ -179,7 +179,7 @@ static void test_WsResetChannel(void)
ok( hr == S_OK, "got %08x\n", hr );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenChannel( channel, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -301,7 +301,7 @@ static void test_WsOpenListener(void)
hr = WsOpenListener( listener, NULL, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- url.length = sizeof(str)/sizeof(str[0]);
+ url.length = ARRAY_SIZE( str );
url.chars = str;
hr = WsOpenListener( NULL, &url, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
@@ -320,7 +320,7 @@ static void test_WsOpenListener(void)
hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- url.length = sizeof(str2)/sizeof(str2[0]);
+ url.length = ARRAY_SIZE( str2 );
url.chars = str2;
hr = WsOpenListener( listener, &url, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -333,7 +333,7 @@ static void test_WsOpenListener(void)
hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- url.length = sizeof(str3)/sizeof(str3[0]);
+ url.length = ARRAY_SIZE( str3 );
url.chars = str3;
hr = WsOpenListener( listener, &url, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -387,7 +387,7 @@ static void test_WsResetListener(void)
{
WCHAR str[] =
{'n','e','t','.','t','c','p',':','/','/','+',':','2','0','1','7','/','p','a','t','h'};
- WS_STRING url = { sizeof(str)/sizeof(str[0]), str };
+ WS_STRING url = { ARRAY_SIZE( str ), str };
WS_LISTENER *listener;
WS_LISTENER_STATE state;
WS_LISTENER_PROPERTY prop;
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index 550ae1dd0d..22d69ece2c 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -258,7 +258,7 @@ static void test_WsAddressMessage(void)
memset( &endpoint, 0, sizeof(endpoint) );
endpoint.url.chars = localhost;
- endpoint.url.length = sizeof(localhost)/sizeof(localhost[0]);
+ endpoint.url.length = ARRAY_SIZE( localhost );
hr = WsAddressMessage( msg, &endpoint, NULL );
ok( hr == S_OK, "got %08x\n", hr );
diff --git a/dlls/webservices/tests/proxy.c b/dlls/webservices/tests/proxy.c
index 95f980a2ff..f5297796b3 100644
--- a/dlls/webservices/tests/proxy.c
+++ b/dlls/webservices/tests/proxy.c
@@ -164,7 +164,7 @@ static void test_WsOpenServiceProxy(void)
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -206,7 +206,7 @@ static void test_WsResetServiceProxy(void)
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -385,7 +385,7 @@ static HRESULT create_proxy( int port, WS_SERVICE_PROXY **ret )
*ret = NULL;
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
- 0, prop, sizeof(prop)/sizeof(prop[0]), &proxy, NULL );
+ 0, prop, ARRAY_SIZE( prop ), &proxy, NULL );
if (hr != S_OK) return hr;
memset( &addr, 0, sizeof(addr) );
@@ -687,7 +687,7 @@ static DWORD CALLBACK server_proc( void *arg )
}
buf[i] = 0;
- for (j = 0; j < sizeof(tests)/sizeof(tests[0]); j++)
+ for (j = 0; j < ARRAY_SIZE( tests ); j++)
{
if (strstr( buf, tests[j].req_action ))
{
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index bd8a37cc52..b21e8396be 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -479,7 +479,7 @@ static void test_WsSetInput(void)
enc.encoding.encodingType = WS_XML_READER_ENCODING_TYPE_TEXT;
enc.charSet = WS_CHARSET_AUTO;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
input.encodedData = tests[i].data;
input.encodedDataSize = tests[i].size;
@@ -1174,7 +1174,7 @@ static void test_WsReadNode(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_input( reader, tests[i].text, strlen(tests[i].text) );
ok( hr == S_OK, "got %08x\n", hr );
@@ -1644,7 +1644,7 @@ static void test_WsReadType(void)
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
enum_desc.values = enum_values;
- enum_desc.valueCount = sizeof(enum_values)/sizeof(enum_values[0]);
+ enum_desc.valueCount = ARRAY_SIZE( enum_values );
enum_desc.maxByteCount = 3;
enum_desc.nameIndices = NULL;
@@ -3526,7 +3526,7 @@ static void test_datetime(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
memset( &date, 0, sizeof(date) );
prepare_type_test( reader, tests[i].str, strlen(tests[i].str) );
@@ -3578,7 +3578,7 @@ static void test_WsDateTimeToFileTime(void)
hr = WsDateTimeToFileTime( NULL, &ft, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
memset( &ft, 0, sizeof(ft) );
hr = WsDateTimeToFileTime( &tests[i].dt, &ft, NULL );
@@ -3716,7 +3716,7 @@ static void test_double(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
val = 0;
prepare_type_test( reader, tests[i].str, strlen(tests[i].str) );
@@ -4064,7 +4064,7 @@ static void test_entities(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_input( reader, tests[i].str, strlen(tests[i].str) );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -4628,7 +4628,7 @@ static void test_WsReadQualifiedName(void)
hr = WsReadQualifiedName( reader, heap, NULL, &localname, NULL, NULL );
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_input( reader, tests[i].str, strlen(tests[i].str) );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -5647,7 +5647,7 @@ static void test_dictionary(void)
UuidCreate( &dict.guid );
dict.strings = strings;
- dict.stringCount = sizeof(strings)/sizeof(strings[0]);
+ dict.stringCount = ARRAY_SIZE( strings );
dict.isConst = TRUE;
/* short dictionary element */
@@ -6385,7 +6385,7 @@ static void test_float(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
val = 0;
prepare_type_test( reader, tests[i].str, strlen(tests[i].str) );
diff --git a/dlls/webservices/tests/url.c b/dlls/webservices/tests/url.c
index 82059a02bf..2b8dda482e 100644
--- a/dlls/webservices/tests/url.c
+++ b/dlls/webservices/tests/url.c
@@ -131,7 +131,7 @@ static void test_WsDecodeUrl(void)
hr = WsDecodeUrl( &str, 0, NULL, (WS_URL **)&url, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
static const WCHAR netpipe[] = {'n','e','t','.','p','i','p','e'};
@@ -271,7 +271,7 @@ static void test_WsEncodeUrl(void)
hr = WsEncodeUrl( (const WS_URL *)&url, 0, heap, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
memset( &url, 0, sizeof(url) );
url.url.scheme = tests[i].scheme;
diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c
index 15d4569662..e33c38951e 100644
--- a/dlls/webservices/tests/writer.c
+++ b/dlls/webservices/tests/writer.c
@@ -710,7 +710,7 @@ static void test_basic_type(void)
ok( hr == S_OK, "got %08x\n", hr );
/* element content type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
prepare_basic_type_test( writer );
hr = WsWriteType( writer, WS_ELEMENT_CONTENT_TYPE_MAPPING, tests[i].type, NULL,
@@ -723,7 +723,7 @@ static void test_basic_type(void)
}
/* element type mapping is the same as element content type mapping for basic types */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
const INT64 *ptr = &tests[i].val;
@@ -738,7 +738,7 @@ static void test_basic_type(void)
}
/* attribute type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
prepare_basic_type_test( writer );
hr = WsWriteStartAttribute( writer, NULL, &localname, &ns, FALSE, NULL );
@@ -1103,7 +1103,7 @@ static void test_WsWriteValue(void)
ok( hr == E_INVALIDARG, "got %08x\n", hr );
/* element type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -1120,7 +1120,7 @@ static void test_WsWriteValue(void)
}
/* attribute type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2170,7 +2170,7 @@ static void test_text_types(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2257,7 +2257,7 @@ static void test_double(void)
ok( hr == S_OK, "got %08x\n", hr );
text.text.textType = WS_XML_TEXT_TYPE_DOUBLE;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2772,7 +2772,7 @@ static void test_escapes(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests_elem)/sizeof(tests_elem[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_elem ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -2789,7 +2789,7 @@ static void test_escapes(void)
check_output( writer, tests_elem[i].result, __LINE__ );
}
- for (i = 0; i < sizeof(tests_attr)/sizeof(tests_attr[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_attr ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -2812,7 +2812,7 @@ static void test_escapes(void)
check_output( writer, tests_attr[i].result, __LINE__ );
}
- for (i = 0; i < sizeof(tests_cdata)/sizeof(tests_cdata[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_cdata ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -2835,7 +2835,7 @@ static void test_escapes(void)
check_output( writer, tests_cdata[i].result, __LINE__ );
}
- for (i = 0; i < sizeof(tests_comment)/sizeof(tests_comment[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_comment ); i++)
{
WS_XML_COMMENT_NODE comment = {{WS_XML_NODE_TYPE_COMMENT}};
@@ -2954,7 +2954,7 @@ static void test_write_option(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3041,7 +3041,7 @@ static void test_datetime(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -3231,7 +3231,7 @@ static void test_WsWriteQualifiedName(void)
hr = WsWriteQualifiedName( writer, NULL, NULL, NULL, NULL );
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
WS_XML_STRING prefix2, localname2, ns2;
const WS_XML_STRING *prefix_ptr, *localname_ptr, *ns_ptr;
@@ -3551,7 +3551,7 @@ static void test_binary_encoding(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(elem_tests)/sizeof(elem_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( elem_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3574,7 +3574,7 @@ static void test_binary_encoding(void)
if (hr == S_OK) check_output_bin( writer, elem_tests[i].result, elem_tests[i].len_result, __LINE__ );
}
- for (i = 0; i < sizeof(attr_tests)/sizeof(attr_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( attr_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3778,12 +3778,12 @@ static void test_dictionary(void)
UuidCreate( &dict.guid );
dict.strings = strings;
- dict.stringCount = sizeof(strings)/sizeof(strings[0]);
+ dict.stringCount = ARRAY_SIZE( strings );
dict.isConst = TRUE;
bin.staticDictionary = &dict;
- for (i = 0; i < sizeof(elem_tests)/sizeof(elem_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( elem_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3799,7 +3799,7 @@ static void test_dictionary(void)
if (hr == S_OK) check_output_bin( writer, elem_tests[i].result, elem_tests[i].len_result, __LINE__ );
}
- for (i = 0; i < sizeof(attr_tests)/sizeof(attr_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( attr_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
--
2.14.4
June 8, 2018
[PATCH] windowscodecs/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/windowscodecs/tests/info.c | 10 ++++----
dlls/windowscodecs/tests/metadata.c | 46 +++++++++++++++++------------------
dlls/windowscodecs/tests/palette.c | 2 +-
dlls/windowscodecs/tests/pngformat.c | 2 +-
dlls/windowscodecs/tests/tiffformat.c | 2 +-
5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/dlls/windowscodecs/tests/info.c b/dlls/windowscodecs/tests/info.c
index d00e9d8338..b647601495 100644
--- a/dlls/windowscodecs/tests/info.c
+++ b/dlls/windowscodecs/tests/info.c
@@ -119,7 +119,7 @@ static void test_decoder_info(void)
UINT num_formats, count;
int i, j;
- for (i = 0; i < sizeof(decoder_info_tests)/sizeof(decoder_info_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(decoder_info_tests); i++)
{
struct decoder_info_test *test = &decoder_info_tests[i];
IWICBitmapDecoder *decoder, *decoder2;
@@ -149,8 +149,8 @@ static void test_decoder_info(void)
}
IWICBitmapDecoder_Release(decoder);
- MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, sizeof(mimetypeW)/sizeof(mimetypeW[0]));
- MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, sizeof(extensionsW)/sizeof(extensionsW[0]));
+ MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, ARRAY_SIZE(mimetypeW));
+ MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, ARRAY_SIZE(extensionsW));
hr = get_component_info(test->clsid, &info);
ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
@@ -234,8 +234,8 @@ static void test_decoder_info(void)
ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
count = 0xdeadbeef;
- hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, sizeof(pixelformats)/sizeof(pixelformats[0]),
- pixelformats, &count);
+ hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, ARRAY_SIZE(pixelformats),
+ pixelformats, &count);
ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index c54d7dfe18..eb846db0b8 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -816,7 +816,7 @@ static void test_metadata_IFD(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -832,7 +832,7 @@ static void test_metadata_IFD(void)
load_stream((IUnknown *)reader, IFD_data_swapped, sizeof(IFD_data), persist_options);
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
HeapFree(GetProcessHeap(), 0, IFD_data_swapped);
@@ -1271,7 +1271,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(gif_LSD)/sizeof(gif_LSD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(gif_LSD), "unexpected count %u\n", count);
compare_metadata(reader, gif_LSD, count);
@@ -1320,7 +1320,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(gif_IMD)/sizeof(gif_IMD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(gif_IMD), "unexpected count %u\n", count);
compare_metadata(reader, gif_IMD, count);
@@ -1374,7 +1374,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_LSD)/sizeof(animated_gif_LSD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_LSD), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_LSD, count);
@@ -1393,7 +1393,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_APE)/sizeof(animated_gif_APE[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_APE), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_APE, count);
@@ -1412,7 +1412,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_comment_1)/sizeof(animated_gif_comment_1[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_comment_1), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_comment_1, count);
@@ -1431,7 +1431,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_plain_1)/sizeof(animated_gif_plain_1[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_plain_1), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_plain_1, count);
@@ -1480,7 +1480,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_IMD)/sizeof(animated_gif_IMD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_IMD), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_IMD, count);
@@ -1499,7 +1499,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_comment_2)/sizeof(animated_gif_comment_2[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_comment_2), "unexpected count %u\n", count);
if (count == 1)
compare_metadata(reader, animated_gif_comment_2, count);
@@ -1519,7 +1519,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_plain_2)/sizeof(animated_gif_plain_2[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_plain_2), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_plain_2, count);
@@ -1538,7 +1538,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_GCE)/sizeof(animated_gif_GCE[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_GCE), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_GCE, count);
@@ -1599,7 +1599,7 @@ static void test_metadata_gif(void)
ok(len == 2, "expected 2, got %u\n", len);
ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name));
- for (i = 0; i < sizeof(decoder_data)/sizeof(decoder_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(decoder_data); i++)
{
WCHAR queryW[256];
@@ -1622,7 +1622,7 @@ static void test_metadata_gif(void)
ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len);
ok(!lstrcmpW(name, queryW), "expected %s, got %s\n", wine_dbgstr_w(queryW), wine_dbgstr_w(name));
- for (j = 0; j < sizeof(decoder_data)/sizeof(decoder_data[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(decoder_data); j++)
{
MultiByteToWideChar(CP_ACP, 0, decoder_data[j].query, -1, queryW, 256);
@@ -1698,7 +1698,7 @@ static void test_metadata_gif(void)
ok(len == 2, "expected 2, got %u\n", len);
ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name));
- for (i = 0; i < sizeof(frame_data)/sizeof(frame_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(frame_data); i++)
{
if (winetest_debug > 1)
trace("query: %s\n", frame_data[i].query);
@@ -1812,7 +1812,7 @@ static void test_metadata_LSD(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -1890,7 +1890,7 @@ static void test_metadata_IMD(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -1965,7 +1965,7 @@ static void test_metadata_GCE(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -2038,7 +2038,7 @@ static void test_metadata_APE(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -2122,7 +2122,7 @@ static void test_metadata_GIF_comment(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -2425,9 +2425,9 @@ static void test_WICMapSchemaToName(void)
return;
}
- for (i = 0; i < sizeof(guid_list)/sizeof(guid_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(guid_list); i++)
{
- for (j = 0; j < sizeof(schema_list)/sizeof(schema_list[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(schema_list); j++)
{
hr = WICMapSchemaToName(guid_list[i], schema_list[j], 0, NULL, &len);
if (IsEqualGUID(guid_list[i], &GUID_MetadataFormatXMP) ||
@@ -2959,7 +2959,7 @@ static void test_queryreader(void)
hr = IWICComponentFactory_CreateQueryReaderFromBlockReader(factory, &mdbr, &reader);
ok(hr == S_OK, "CreateQueryReaderFromBlockReader error %#x\n", hr);
- for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(test_data); i++)
{
current_metadata = test_data[i].data;
diff --git a/dlls/windowscodecs/tests/palette.c b/dlls/windowscodecs/tests/palette.c
index e3b9a313f6..27bf7c80d1 100644
--- a/dlls/windowscodecs/tests/palette.c
+++ b/dlls/windowscodecs/tests/palette.c
@@ -473,7 +473,7 @@ static void test_predefined_palette(void)
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
IWICPalette_Release(palette);
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
hr = IWICImagingFactory_CreatePalette(factory, &palette);
ok(hr == S_OK, "%u: CreatePalette error %#x\n", i, hr);
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
index 4b84ccebb1..c798ea438d 100644
--- a/dlls/windowscodecs/tests/pngformat.c
+++ b/dlls/windowscodecs/tests/pngformat.c
@@ -717,7 +717,7 @@ static void test_color_formats(void)
* with tEXt id.
*/
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
/* with the tRNS and PLTE chunks */
memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c
index a7b6f5b594..c6ec21ada1 100644
--- a/dlls/windowscodecs/tests/tiffformat.c
+++ b/dlls/windowscodecs/tests/tiffformat.c
@@ -454,7 +454,7 @@ static void test_tiff_resolution(void)
double dpi_x, dpi_y;
int i;
- for (i = 0; i < sizeof(tiff_resolution_test_data)/sizeof(tiff_resolution_test_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tiff_resolution_test_data); i++)
{
const struct tiff_resolution_test_data *test_data = &tiff_resolution_test_data[i];
tiff_resolution_image_data.resx = test_data->resx;
--
2.14.4
June 8, 2018
Re: [PATCH] gdiplus/tests: Use the available ARRAY_SIZE() macro
by Vincent Povirk
Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com>
June 8, 2018
Re: [PATCH v2] shellpath.c: Fix creation of HOME directory symbolic links
by Huw Davies
On Fri, Jun 08, 2018 at 10:58:23AM +0100, Rob Walker wrote:
> Fixes: https://bugs.winehq.org/show_bug.cgi?id=41668
>
> The Shell Folders, that Wine symlinks to the user's HOME directory, are
> only re-created on each Wine boot if they: do not pre-exist or are broken
> symbolic links.
>
> Handling the DESKTOP Shell Folder is a special case as this is created twice
> (during a standard boot), early in the Wine boot process. This is handled by
> 2 separate processes, loading shell32.dll, in sequence. This makes it hard to determine
> if the DESKTOP folder was created before the Wine boot (either from a previous Wine boot
> or by the end user).
>
> The final (implemented) solution determines the exact start time of the Wine boot process
> (using the current system time and tick-count). If the DESKTOP directory was last written
> after this Wine boot time, we can assume that "we" (Wine) automatically created the
> directory. Only in this instance do we attempt to set a symlink to the DESKTOP directory
> (subdirectory of HOME).
There's still too much going on here.
Do you really need to refactor the code to make your change?
If not, then just send in the change to the current code.
If you need to refactor, then do the refactoring first
(I could imagine taking 3-4 patches to do the refactoring[1])
then make the change as a final patch in the series.
The file-time / boot-time thing seems hacky, I'm not exactly
sure what you're trying do to, but this doesn't sound right.
Hopefully that will become clearer as you tidy things up.
Huw.
[1] For example move the creation of My Pictures/My Videos/etc
first, then move My Documents and finally Desktop. These
final two are special cases in the current code, we'd need
to see that in any new code.
June 8, 2018
[PATCH v2] shellpath.c: Fix creation of HOME directory symbolic links
by Rob Walker
Fixes: https://bugs.winehq.org/show_bug.cgi?id=41668
The Shell Folders, that Wine symlinks to the user's HOME directory, are
only re-created on each Wine boot if they: do not pre-exist or are broken
symbolic links.
Handling the DESKTOP Shell Folder is a special case as this is created twice
(during a standard boot), early in the Wine boot process. This is handled by
2 separate processes, loading shell32.dll, in sequence. This makes it hard to determine
if the DESKTOP folder was created before the Wine boot (either from a previous Wine boot
or by the end user).
The final (implemented) solution determines the exact start time of the Wine boot process
(using the current system time and tick-count). If the DESKTOP directory was last written
after this Wine boot time, we can assume that "we" (Wine) automatically created the
directory. Only in this instance do we attempt to set a symlink to the DESKTOP directory
(subdirectory of HOME).
Test on Gentoo GNU/Linux.
Signed-off-by: Rob Walker <bob.mt.wya(a)gmail.com>
---
dlls/shell32/shellpath.c | 325 ++++++++++++++++++---------------------
1 file changed, 151 insertions(+), 174 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index a551e93aa8..c87c73846b 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -58,6 +58,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
static const BOOL is_win64 = sizeof(void *) > sizeof(int);
+static LONG register_shell_folders = 0;
/*
########## Combining and Constructing paths ##########
@@ -4098,6 +4099,15 @@ HRESULT WINAPI SHGetFolderPathAndSubDirW(
goto end;
}
+ /* Allow function create_homedir_symbolic_link create this directory
+ (or a HOME directory symlink) for us, later in the boot process. */
+ if (!InterlockedCompareExchange(®ister_shell_folders, -1, -1) && (folder == CSIDL_DESKTOPDIRECTORY))
+ {
+ TRACE("Faking successful creation of system directory %s (%#x)\n", debugstr_w(szBuildPath), folder);
+ hr = S_OK;
+ goto end;
+ }
+
/* create directory/directories */
ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
if (ret && ret != ERROR_ALREADY_EXISTS)
@@ -4107,7 +4117,7 @@ HRESULT WINAPI SHGetFolderPathAndSubDirW(
goto end;
}
- TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
+ TRACE("Created missing system directory %s (%#x)\n", debugstr_w(szBuildPath), folder);
end:
TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
return hr;
@@ -4385,193 +4395,111 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
}
/******************************************************************************
- * _SHCreateSymbolicLinks [Internal]
- *
- * Sets up symbol links for various shell folders to point into the users home
- * directory. We do an educated guess about what the user would probably want:
- * - If there is a 'My Documents' directory in $HOME, the user probably wants
- * wine's 'My Documents' to point there. Furthermore, we imply that the user
- * is a Windows lover and has no problem with wine creating 'My Pictures',
- * 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those
- * do not already exits. We put appropriate symbolic links in place for those,
- * too.
- * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
- * point directly to $HOME. We assume the user to be a unix hacker who does not
- * want wine to create anything anywhere besides the .wine directory. So, if
- * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
- * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
- * directory, and try to link to that. If that fails, then we symlink to
- * $HOME directly. The same holds fo 'My Pictures' and 'My Videos'.
- * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
- * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
- * it alone.
- * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
+ * create_homedir_symbolic_link [Internal]
+ *
+ * Creates a symbolic link from the current Wineprefix to an appropriate
+ * HOME subdirectory (if one is found).
+ *
+ * Creates 'XXXX' directory in Wineprefix.
+ * Then create a 'My XXXX' symbolic link in Wineprefix:
+ * 1) If '$HOME/XXXX' (IDS directory) exists then target this.
+ * 2) If '$HOME/XXXX' (XDG_XXXX_DIR) exists then target this.
+ * 3) If '$HOME/XXXX' (MacOS XXXX media directory) exists then target this.
+ *
+ * PARAMS
+ * ids_dir [I] Windows Resource Identifier code for current Shell Folder.
+ * csidl_dir [I] Constant Special Item ID List identifier for current Shell Folder.
+ * xdg_dir [I] Full path of external Unix XDG directory corresponding to current Shell Folder.
+ * ws_osx_dir [I] Fallback directory name to use, corresponding to current Shell Folder (OSX specific).
+ *
*/
-static void _SHCreateSymbolicLinks(void)
-{
- UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC }, i;
- const WCHAR* MyOSXStuffW[] = { PicturesW, MoviesW, MusicW };
- int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC };
- static const char * const xdg_dirs[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
- static const unsigned int num = ARRAY_SIZE(xdg_dirs);
- WCHAR wszTempPath[MAX_PATH];
- char szPersonalTarget[FILENAME_MAX], *pszPersonal;
- char szMyStuffTarget[FILENAME_MAX], *pszMyStuff;
- char szDesktopTarget[FILENAME_MAX], *pszDesktop;
- struct stat statFolder;
- const char *pszHome;
+void create_homedir_symbolic_link(UINT ids_dir,
+ int csidl_dir,
+ const char * xdg_dir,
+ const WCHAR * ws_osx_dir)
+{
+ static const char * env_homedir = NULL;
+ WCHAR ws_temp_path[MAX_PATH];
+ char home_target[FILENAME_MAX], * prefix_dir;
+ struct stat stat_folder, stat_home_folder;
HRESULT hr;
- char ** xdg_results;
- char * xdg_desktop_dir;
-
- /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
- hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL,
- SHGFP_TYPE_DEFAULT, wszTempPath);
- if (FAILED(hr)) return;
- pszPersonal = wine_get_unix_file_name(wszTempPath);
- if (!pszPersonal) return;
+ BOOL target_ok;
- hr = XDG_UserDirLookup(xdg_dirs, num, &xdg_results);
- if (FAILED(hr)) xdg_results = NULL;
-
- pszHome = getenv("HOME");
- if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode))
+ hr = SHGetFolderPathW(NULL, csidl_dir, NULL,
+ SHGFP_TYPE_DEFAULT, ws_temp_path);
+ if (SUCCEEDED(hr))
{
- while (1)
- {
- /* Check if there's already a Wine-specific 'My Documents' folder */
- strcpy(szPersonalTarget, pszHome);
- if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) &&
- !stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
- {
- /* '$HOME/My Documents' exists. Create 'My Pictures',
- * 'My Videos' and 'My Music' subfolders or fail silently if
- * they already exist.
- */
- for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++)
- {
- strcpy(szMyStuffTarget, szPersonalTarget);
- if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
- mkdir(szMyStuffTarget, 0777);
- }
- break;
- }
-
- /* Try to point to the XDG Documents folder */
- if (xdg_results && xdg_results[num-2] &&
- !stat(xdg_results[num-2], &statFolder) &&
- S_ISDIR(statFolder.st_mode))
- {
- strcpy(szPersonalTarget, xdg_results[num-2]);
- break;
- }
-
- /* Or the hardcoded / OS X Documents folder */
- strcpy(szPersonalTarget, pszHome);
- if (_SHAppendToUnixPath(szPersonalTarget, DocumentsW) &&
- !stat(szPersonalTarget, &statFolder) &&
- S_ISDIR(statFolder.st_mode))
- break;
-
- /* As a last resort point to $HOME. */
- strcpy(szPersonalTarget, pszHome);
- break;
- }
-
- /* Replace 'My Documents' directory with a symlink or fail silently if not empty. */
- remove(pszPersonal);
- symlink(szPersonalTarget, pszPersonal);
+ TRACE("%s directory already exists\n",
+ debugstr_w(ws_temp_path));
+ return;
+ }
+ else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
+ {
+ hr = SHGetFolderPathW(NULL, csidl_dir|CSIDL_FLAG_CREATE, NULL,
+ SHGFP_TYPE_DEFAULT, ws_temp_path);
+ if (FAILED(hr)) return;
}
else
{
- /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
- * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
- pszHome = NULL;
- strcpy(szPersonalTarget, pszPersonal);
- for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) {
- strcpy(szMyStuffTarget, szPersonalTarget);
- if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
- mkdir(szMyStuffTarget, 0777);
- }
+ ERR("Failed to get Wineprefix path corresponding to %d CSIDL\n",
+ csidl_dir);
+ return;
}
- /* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
- for (i=0; i < ARRAY_SIZE(aidsMyStuff); i++)
+ prefix_dir = wine_get_unix_file_name(ws_temp_path);
+ if (!prefix_dir)
{
- /* Create the current 'My Whatever' folder and get its unix path. */
- hr = SHGetFolderPathW(NULL, acsidlMyStuff[i]|CSIDL_FLAG_CREATE, NULL,
- SHGFP_TYPE_DEFAULT, wszTempPath);
- if (FAILED(hr)) continue;
-
- pszMyStuff = wine_get_unix_file_name(wszTempPath);
- if (!pszMyStuff) continue;
-
- while (1)
- {
- /* Check for the Wine-specific '$HOME/My Documents' subfolder */
- strcpy(szMyStuffTarget, szPersonalTarget);
- if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])) &&
- !stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
- break;
-
- /* Try the XDG_XXX_DIR folder */
- if (xdg_results && xdg_results[i])
- {
- strcpy(szMyStuffTarget, xdg_results[i]);
- break;
- }
-
- /* Or the OS X folder (these are never localized) */
- if (pszHome)
- {
- strcpy(szMyStuffTarget, pszHome);
- if (_SHAppendToUnixPath(szMyStuffTarget, MyOSXStuffW[i]) &&
- !stat(szMyStuffTarget, &statFolder) &&
- S_ISDIR(statFolder.st_mode))
- break;
- }
+ ERR("Failed to get Unix Wineprefix directory for: %s\n",
+ debugstr_w(ws_temp_path));
+ return;
+ }
- /* As a last resort point to the same location as 'My Documents' */
- strcpy(szMyStuffTarget, szPersonalTarget);
- break;
- }
- remove(pszMyStuff);
- symlink(szMyStuffTarget, pszMyStuff);
- heap_free(pszMyStuff);
+ if (!env_homedir) env_homedir = getenv("HOME");
+ if (!(env_homedir
+ && (stat(env_homedir, &stat_home_folder) != 1)
+ && S_ISDIR(stat_home_folder.st_mode)))
+ {
+ if (prefix_dir) heap_free(prefix_dir);
+ return;
}
- /* Last but not least, the Desktop folder */
- if (pszHome)
- strcpy(szDesktopTarget, pszHome);
+ /* Check for:
+ * '$HOME/XXXX' (IDS directory)
+ * or '$HOME/XXXX' (XDG directory)
+ * or '$HOME/XXXX' (MacOS directory)
+ */
+ target_ok = FALSE;
+ strcpy(home_target, env_homedir);
+ if (_SHAppendToUnixPath(home_target, MAKEINTRESOURCEW(ids_dir))
+ && (stat(home_target, &stat_folder) != -1)
+ && S_ISDIR(stat_folder.st_mode))
+ {
+ target_ok = TRUE;
+ }
+ else if (xdg_dir)
+ {
+ strcpy(home_target, xdg_dir);
+ /* Only link to the XDG directory, if it does not point directly
+ * to the user's HOME directory (XDG specification fallback path). */
+ target_ok = TRUE;
+ }
else
- strcpy(szDesktopTarget, pszPersonal);
- heap_free(pszPersonal);
-
- xdg_desktop_dir = xdg_results ? xdg_results[num - 1] : NULL;
- if (xdg_desktop_dir ||
- (_SHAppendToUnixPath(szDesktopTarget, DesktopW) &&
- !stat(szDesktopTarget, &statFolder) && S_ISDIR(statFolder.st_mode)))
{
- hr = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, NULL,
- SHGFP_TYPE_DEFAULT, wszTempPath);
- if (SUCCEEDED(hr) && (pszDesktop = wine_get_unix_file_name(wszTempPath)))
- {
- remove(pszDesktop);
- if (xdg_desktop_dir)
- symlink(xdg_desktop_dir, pszDesktop);
- else
- symlink(szDesktopTarget, pszDesktop);
- heap_free(pszDesktop);
- }
+ strcpy(home_target, env_homedir);
+ target_ok = _SHAppendToUnixPath(home_target, ws_osx_dir)
+ && (stat(home_target, &stat_folder) != -1)
+ && S_ISDIR(stat_folder.st_mode);
}
- /* Free resources allocated by XDG_UserDirLookup() */
- if (xdg_results)
+ if (target_ok)
{
- for (i = 0; i < num; i++)
- heap_free(xdg_results[i]);
- heap_free(xdg_results);
+ TRACE("Delete path: %s\n", debugstr_a(prefix_dir));
+ remove(prefix_dir);
+ TRACE("Symlink: %s -> %s\n", debugstr_a(prefix_dir), debugstr_a(home_target));
+ symlink(home_target, prefix_dir);
}
+
+ if (prefix_dir) heap_free(prefix_dir);
}
/******************************************************************************
@@ -6126,15 +6054,61 @@ static void register_system_knownfolders(void)
}
}
+/******************************************************************************
+ * create_homedir_symbolic_links [Internal]
+ *
+ * Parse WINESYMLINK env variable, for each XDG directory argument. To test if symlinking is
+ * enabled for that XDG directory / Wine Profile Folder.
+ * Then calls the function create_homedir_symbolic_link to potentially symlink from a Shell Folder,
+ * in the current Wineprefix, to a subdirectory of the current user's HOME directory.
+ *
+ * PARAMS
+ * xdg_dirnames [I] Pointer to an array of Unix XDG directory names
+ * (without "XDG_" prefix and "_DIR" suffix).
+ * xdg_dir_count [I] Item count of array (above).
+ *
+ */
+static void create_homedir_symbolic_links(const char * const xdg_dirnames[], const UINT xdg_dir_count)
+{
+ char ** xdg_dirs_array;
+ char * xdg_dir;
+ HRESULT hr;
+ UINT i;
+
+ if (!xdg_dirnames) return;
+
+ hr = XDG_UserDirLookup(xdg_dirnames, xdg_dir_count, &xdg_dirs_array);
+ if (FAILED(hr)) xdg_dirs_array = NULL;
+
+ for (i = 0; i < xdg_dir_count; ++i)
+ {
+ xdg_dir = xdg_dirs_array ? xdg_dirs_array[i] : NULL;
+ if (!strcmp(xdg_dirnames[i],"DOCUMENTS"))
+ create_homedir_symbolic_link(IDS_PERSONAL, CSIDL_PERSONAL, xdg_dir, DocumentsW);
+ else if (!strcmp(xdg_dirnames[i],"PICTURES"))
+ create_homedir_symbolic_link(IDS_MYPICTURES, CSIDL_MYPICTURES, xdg_dir, PicturesW);
+ else if (!strcmp(xdg_dirnames[i],"VIDEOS"))
+ create_homedir_symbolic_link(IDS_MYVIDEOS, CSIDL_MYVIDEO, xdg_dir, MoviesW);
+ else if (!strcmp(xdg_dirnames[i],"MUSIC"))
+ create_homedir_symbolic_link(IDS_MYMUSIC, CSIDL_MYMUSIC, xdg_dir, MusicW);
+ else if (!strcmp(xdg_dirnames[i],"DESKTOP"))
+ create_homedir_symbolic_link(IDS_DESKTOPDIRECTORY, CSIDL_DESKTOPDIRECTORY, xdg_dir, DesktopW);
+ else
+ ERR("XDG directory name specifier invalid: %s\n", debugstr_a(xdg_dirnames[i]));
+ if (xdg_dir) heap_free(xdg_dirs_array[i]);
+ }
+ if (xdg_dirs_array) heap_free(xdg_dirs_array);
+}
+
HRESULT SHELL_RegisterShellFolders(void)
{
+ static const char * const xdg_dirnames[] = { "DOCUMENTS", "PICTURES", "VIDEOS", "MUSIC", "DESKTOP" };
+ const UINT xdg_dir_count = 5;
HRESULT hr;
- /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
- * 'My Videos', 'My Music' and 'Desktop' in advance, so that the
- * _SHRegister*ShellFolders() functions will find everything nice and clean
- * and thus will not attempt to create them in the profile directory. */
- _SHCreateSymbolicLinks();
+ /* Early setup of symlinks from specific User Shell Folders, in
+ * current Wineprefix, to subdirecties of the user's HOME directory. */
+ create_homedir_symbolic_links(xdg_dirnames, xdg_dir_count);
hr = _SHRegisterUserShellFolders(TRUE);
if (SUCCEEDED(hr))
@@ -6147,5 +6121,8 @@ HRESULT SHELL_RegisterShellFolders(void)
hr = set_folder_attributes();
if (SUCCEEDED(hr))
register_system_knownfolders();
+
+ (void) InterlockedExchange(®ister_shell_folders, 1);
+
return hr;
}
--
2.17.1
June 8, 2018
Re: [PATCH 4/4] wsdapi: Add initial support for reading messages; identify Probe message.
by Owen Rudge
> It's mainly just for consistency. I don't feel particularly strongly
> about it in these cases, however in previous patch-sets I let similar
> things go, only for it later to become apparent that I shouldn't have.
Although these functions are not used in my upcoming patches, I suppose it's feasible that one day they could be used by callers that could make use of the result, so I'll look at amending that.
> It certainly can't be left like this at the end of the patch-set. It
> might be ok (since this isn't exactly a core dll) to include the next
> patch so that the implementation doesn't regress as far as the tests
> are concerned.
OK, I can include the patch that will fix the TODO in the patchset, which I think would likely be the simplest way of resolving this.
Thanks,
Owen
June 8, 2018
Re: [PATCH 4/4] wsdapi: Add initial support for reading messages; identify Probe message.
by Huw Davies
On Thu, Jun 07, 2018 at 09:15:02PM +0100, Owen Rudge wrote:
> On 07/06/2018 08:56, Huw Davies wrote:
>
> >> +static BOOL move_to_element(WS_XML_READER *reader, const char
> *element_name, WS_XML_STRING *uri)
> >
> > return HRESULT
> >
> >> +static BOOL ws_element_to_wsdxml_element(WS_XML_READER *reader,
> IWSDXMLContext *context, WSDXML_ELEMENT *parent_element)
> >
> > and here.
> >
> >> int read_message(const char *xml, int xml_length, WSD_SOAP_MESSAGE
> **out_msg)
> >
> > This is also looking like a good contender to return HRESULT and
> > take an [out] int *type parameter.
>
> As per the previous patch, the HRESULT is not ultimately used, and I can't
> see that there's a great benefit in passing it along. I do understand it for
> the other functions that ultimately return a value to the caller, but these
> functions are all called by the listener thread, and a simple identification
> of the message type is all we require.
>
> If you think it would be beneficial, I can modify these functions to return
> HRESULT, but it would be good to understand the benefits of doing so.
It's mainly just for consistency. I don't feel particularly strongly
about it in these cases, however in previous patch-sets I let similar
things go, only for it later to become apparent that I shouldn't have.
One way to look at it is that conceptually the function has no idea
that the caller cannot use the failure status, so it should return
it regardless.
> >> - ok(any != NULL, "%s: any == NULL\n", debug_prefix);
> >> + todo_wine ok(any != NULL, "%s: any == NULL\n", debug_prefix);
> >
> > You'll need to have a really good reason for doing this. Can you
> > re-order things so you don't break the tests?
>
> This will be fixed in the next patchset; I didn't want to include any more
> code in what's already quite a large patch. There's probably an extra 40 or
> so lines of code needed to avoid this breakage. There's not really a way I
> can re-order this that I can think of.
>
> If preferred though, I can submit the patch that will fix this as part of
> this patchset, so the net result once the set is committed involves no extra
> todos.
It certainly can't be left like this at the end of the patch-set. It
might be ok (since this isn't exactly a core dll) to include the next
patch so that the implementation doesn't regress as far as the tests
are concerned.
Huw.
June 8, 2018
[PATCH 5/5] mstask/tests: Add more tests for IEnumWorkItems interface.
by Dmitry Timoshkov
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/mstask/tests/task_scheduler.c | 75 +++++++++++++++++++++++++++++++++++---
1 file changed, 70 insertions(+), 5 deletions(-)
diff --git a/dlls/mstask/tests/task_scheduler.c b/dlls/mstask/tests/task_scheduler.c
index d4766382ec..f61022575d 100644
--- a/dlls/mstask/tests/task_scheduler.c
+++ b/dlls/mstask/tests/task_scheduler.c
@@ -212,23 +212,88 @@ done:
static void test_Enum(void)
{
+ static const WCHAR Task1[] = { 'w','i','n','e','t','a','s','k','1',0 };
ITaskScheduler *scheduler;
+ ITask *task;
IEnumWorkItems *tasks;
+ WCHAR **names;
+ ULONG fetched;
HRESULT hr;
hr = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
&IID_ITaskScheduler, (void **)&scheduler);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "got %#x\n", hr);
+
+ /* cleanup after previous runs */
+ ITaskScheduler_Delete(scheduler, Task1);
+
+ hr = ITaskScheduler_NewWorkItem(scheduler, Task1, &CLSID_CTask, &IID_ITask, (IUnknown **)&task);
+ ok(hr == S_OK, "got %#x\n", hr);
+ hr = ITaskScheduler_AddWorkItem(scheduler, Task1, (IScheduledWorkItem *)task);
+ ok(hr == S_OK, "got %#x\n", hr);
+
+ ITask_Release(task);
-if (0) { /* crashes on win2k */
hr = ITaskScheduler_Enum(scheduler, NULL);
- ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
-}
+ ok(hr == E_INVALIDARG, "got %#x\n", hr);
hr = ITaskScheduler_Enum(scheduler, &tasks);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "got %#x\n", hr);
+
+ names = (void *)0xdeadbeef;
+ fetched = 0xdeadbeef;
+ hr = IEnumWorkItems_Next(tasks, 0, &names, &fetched);
+ ok(hr == E_INVALIDARG, "got %#x\n", hr);
+ ok(names == (void *)0xdeadbeef, "got %p\n", names);
+ ok(fetched == 0xdeadbeef, "got %#x\n", fetched);
+
+ hr = IEnumWorkItems_Next(tasks, 1, NULL, NULL);
+ ok(hr == E_INVALIDARG, "got %#x\n", hr);
+
+ names = NULL;
+ hr = IEnumWorkItems_Next(tasks, 1, &names, NULL);
+ ok(hr == S_OK, "got %#x\n", hr);
+ ok(names != NULL, "got NULL\n");
+ ok(names[0] != NULL, "got NULL\n");
+ CoTaskMemFree(names[0]);
+ CoTaskMemFree(names);
+
+ names = (void *)0xdeadbeef;
+ hr = IEnumWorkItems_Next(tasks, 2, &names, NULL);
+ ok(hr == E_INVALIDARG, "got %#x\n", hr);
+ ok(names == (void *)0xdeadbeef, "got %p\n", names);
+
+ hr = IEnumWorkItems_Reset(tasks);
+ ok(hr == S_OK, "got %#x\n", hr);
+
+ names = NULL;
+ fetched = 0xdeadbeef;
+ hr = IEnumWorkItems_Next(tasks, 1, &names, &fetched);
+ ok(hr == S_OK, "got %#x\n", hr);
+ ok(names != NULL, "got NULL\n");
+ ok(names[0] != NULL, "got NULL\n");
+ ok(fetched == 1, "got %u\n", fetched);
+ CoTaskMemFree(names[0]);
+ CoTaskMemFree(names);
+
+ while (IEnumWorkItems_Skip(tasks, 1) == S_OK)
+ /* do nothing*/;
+
+ hr = IEnumWorkItems_Skip(tasks, 1);
+ ok(hr == S_FALSE, "got %#x\n", hr);
+
+ names = (void *)0xdeadbeef;
+ fetched = 0xdeadbeef;
+ hr = IEnumWorkItems_Next(tasks, 1, &names, &fetched);
+ ok(hr == S_FALSE, "got %#x\n", hr);
+ ok(names == NULL, "got %p\n", names);
+ ok(fetched == 0, "got %u\n", fetched);
+
IEnumWorkItems_Release(tasks);
+ hr = ITaskScheduler_Delete(scheduler, Task1);
+ ok(hr == S_OK, "got %#x\n", hr);
+
ITaskScheduler_Release(scheduler);
}
--
2.16.3
June 8, 2018