[PATCH v2 0/1] MR10591: winebth.sys: Support building with dbus older than 1.12.
DBUS_MESSAGE_ITER_INIT_CLOSED and dbus_message_iter_abandon_container_if_open were added in dbus 1.12. Provide a fallback definition for the macro and load the function optionally via dlsym to allow building on systems with older dbus. -- v2: winebth.sys: Support building with dbus older than 1.12. https://gitlab.winehq.org/wine/wine/-/merge_requests/10591
From: Vitaly Lipatov <lav@etersoft.ru> dbus_message_iter_abandon_container_if_open was added in dbus 1.12. Drop the dependency on it by tracking the container open state explicitly in bluez_gatt_characteristic_read() and using dbus_message_iter_abandon_container() on the error path when needed. --- dlls/winebth.sys/dbus.c | 10 ++++++++-- dlls/winebth.sys/dbus.h | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/winebth.sys/dbus.c b/dlls/winebth.sys/dbus.c index aa2cef1cc0a..7eb9e4db60b 100644 --- a/dlls/winebth.sys/dbus.c +++ b/dlls/winebth.sys/dbus.c @@ -1109,12 +1109,13 @@ static void bluez_gatt_characteristic_read_callback( DBusPendingCall *pending, v NTSTATUS bluez_gatt_characteristic_read( void *connection, void *watcher_ctx, struct unix_name *characteristic, IRP *irp ) { - DBusMessageIter args_iter, dict_iter = DBUS_MESSAGE_ITER_INIT_CLOSED; + DBusMessageIter args_iter, dict_iter; struct bluez_async_req_data *data = NULL; DBusPendingCall *pending_call = NULL; DBusMessage *request; NTSTATUS status; dbus_bool_t success; + BOOL dict_iter_open = FALSE; TRACE( "(%s, %p)\n", debugstr_a( characteristic->str ), irp ); @@ -1136,11 +1137,13 @@ NTSTATUS bluez_gatt_characteristic_read( void *connection, void *watcher_ctx, st status = STATUS_NO_MEMORY; goto failed; } + dict_iter_open = TRUE; if (!p_dbus_message_iter_close_container( &args_iter, &dict_iter )) { status = STATUS_NO_MEMORY; goto failed; } + dict_iter_open = FALSE; success = p_dbus_connection_send_with_reply( connection, request, &pending_call, bluez_timeout ); if (!success) { @@ -1163,7 +1166,10 @@ NTSTATUS bluez_gatt_characteristic_read( void *connection, void *watcher_ctx, st p_dbus_message_unref( request ); return STATUS_PENDING; failed: - p_dbus_message_iter_abandon_container_if_open( &args_iter, &dict_iter ); + /* Track dict_iter state explicitly instead of using + * dbus_message_iter_abandon_container_if_open, which requires dbus >= 1.12. */ + if (dict_iter_open) + p_dbus_message_iter_abandon_container( &args_iter, &dict_iter ); p_dbus_message_unref( request ); return status; } diff --git a/dlls/winebth.sys/dbus.h b/dlls/winebth.sys/dbus.h index 511e8caf25b..4cbf37883df 100644 --- a/dlls/winebth.sys/dbus.h +++ b/dlls/winebth.sys/dbus.h @@ -84,7 +84,6 @@ DO_FUNC(dbus_message_is_signal); \ DO_FUNC(dbus_message_iter_append_basic); \ DO_FUNC(dbus_message_iter_abandon_container); \ - DO_FUNC(dbus_message_iter_abandon_container_if_open); \ DO_FUNC(dbus_message_iter_close_container); \ DO_FUNC(dbus_message_iter_get_arg_type); \ DO_FUNC(dbus_message_iter_get_element_type); \ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10591
On Tue Apr 14 10:49:04 2026 +0000, Vitaly Lipatov wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/10591/diffs?diff_id=260015&start_sha=f1864a83c05e276a64574d3c28543a35c243e4b7#b1b81150acd177b721a2889cb06e71b3654770a2_1179_1169) I only regret that the feature from the new dbus version will not be used.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10591#note_136055
participants (2)
-
Vitaly Lipatov -
Vitaly Lipatov (@lav)