Fix dict_append_array to accept types other than string
Luiz Augusto von Dentz
maintainerPATCH 1/1 Fix dict_append_array to accept types other than string
From: Luiz Augusto von Dentz <[email protected]>
--- src/dbus-common.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
src/dbus-common.c +11 -5
@@ -210,8 +210,6 @@ static void append_array_variant(DBusMessageIter *iter, int type, void *val,DBusMessageIter variant, array;char type_sig[2 ] = { type,'\0' };char array_sig[3 ] = {DBUS_TYPE_ARRAY , type,'\0' }; -const char ***str_array = val; -int i;dbus_message_iter_open_container (iter,DBUS_TYPE_VARIANT , array_sig, &variant);
@@ -219,9 +217,17 @@ static void append_array_variant(DBusMessageIter *iter, int type, void *val,dbus_message_iter_open_container (&variant,DBUS_TYPE_ARRAY , type_sig, &array); -for (i =0 ; i < n_elements; i++) -dbus_message_iter_append_basic (&array, type, - &((*str_array)[i])); +if (dbus_type_is_fixed (type) == TRUE) { +dbus_message_iter_append_fixed_array (&array, type, val, + n_elements); + }else if (type ==DBUS_TYPE_STRING || type ==DBUS_TYPE_OBJECT_PATH ) { +const char ***str_array = (const char ***) val; +int i; + +for (i =0 ; i < n_elements; i++) +dbus_message_iter_append_basic (&array, type, + &((*str_array)[i])); + }dbus_message_iter_close_container (&variant, &array);
Signature · 1 line
1.7.1
Hi Luiz,
Quoted 5 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
--- src/dbus-common.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
The patch is now upstream, with the following minor change that I did for you:
src/dbus-common.c static void append_array_variant(DBusMessageIter *iter, int type, void *val, · line 224
Quoted 1 line
src/dbus-common.c +1
-0+const char ***str_array = (const char ***) val;
Since val is void * there's no need to do the type cast (the original code didn't do it either).
Johan