diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2011-01-05 15:25:06 -0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2011-01-05 16:19:09 -0800 |
commit | 435e20153c246fa21af12117449a97687053c6f4 (patch) | |
tree | 7b50b66826c610e0f6b91dbe7d2edc17e9992c3b /src/dbus.c | |
parent | 9aa82f5bb1b498c8e3d7b7180b62190d46e39f83 (diff) | |
download | ofono-435e20153c246fa21af12117449a97687053c6f4.tar.bz2 |
dbus: fix appending on dict for types other than string
According to dbus documentation, dbus_message_iter_append_basic()
expects a "const char**" if type is string and a simple pointer for
other types. Since we a iterating an array, the value passed is already
a pointer.
Diffstat (limited to 'src/dbus.c')
-rw-r--r-- | src/dbus.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -139,8 +139,24 @@ static void append_dict_variant(DBusMessageIter *iter, int type, void *val) dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &(val_array[i + 0])); - dbus_message_iter_append_basic(&entry, type, - &(val_array[i + 1])); + + /* + * D-Bus expects a char** or uint8* depending on the type + * given. Since we are dealing with an array through a void** + * (and thus val_array[i] is a pointer) we need to + * differentiate DBUS_TYPE_STRING from the others. The other + * option would be the user to pass the exact type to this + * function, instead of a pointer to it. However in this case + * a cast from type to void* would be needed, which is not + * good. + */ + if (type == DBUS_TYPE_STRING) { + dbus_message_iter_append_basic(&entry, type, + &(val_array[i + 1])); + } else { + dbus_message_iter_append_basic(&entry, type, + val_array[i + 1]); + } dbus_message_iter_close_container(&array, &entry); } |