summaryrefslogtreecommitdiffstats
path: root/src/dbus.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2011-01-05 15:25:06 -0200
committerMarcel Holtmann <marcel@holtmann.org>2011-01-05 16:19:09 -0800
commit435e20153c246fa21af12117449a97687053c6f4 (patch)
tree7b50b66826c610e0f6b91dbe7d2edc17e9992c3b /src/dbus.c
parent9aa82f5bb1b498c8e3d7b7180b62190d46e39f83 (diff)
downloadofono-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.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/dbus.c b/src/dbus.c
index c24615f4..b719217c 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -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);
}