client: Fix build with older version on libdbus
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 26 Feb 2019 17:24:40 +0000 (19:24 +0200)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:57:47 +0000 (14:27 +0530)
This fixes the following error when building with older version of
D-Bus:

client/gatt.c:2973: undefined reference to `dbus_message_iter_get_element_count'

Change-Id: Ie285fced42f67448a6a075f2e65a7726be10956c
Signed-off-by: himanshu <h.himanshu@samsung.com>
client/gatt.c

index cf13d1c..16cfd51 100755 (executable)
@@ -2978,7 +2978,7 @@ static void clone_chrc(struct GDBusProxy *proxy)
        DBusMessageIter iter;
        DBusMessageIter array;
        const char *uuid;
-       char **flags;
+       char *flags[17];
        int i;
 
        if (g_dbus_proxy_get_property(proxy, "UUID", &iter) == FALSE)
@@ -2989,21 +2989,16 @@ static void clone_chrc(struct GDBusProxy *proxy)
        if (g_dbus_proxy_get_property(proxy, "Flags", &iter) == FALSE)
                return;
 
-       flags = g_new0(char *, dbus_message_iter_get_element_count(&iter) + 1);
-
        dbus_message_iter_recurse(&iter, &array);
 
        for (i = 0; dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING;
                                                                        i++) {
-               const char *flag;
-
-               dbus_message_iter_get_basic(&array, &flag);
-
-               flags[i] = g_strdup(flag);
-
+               dbus_message_iter_get_basic(&array, &flags[i]);
                dbus_message_iter_next(&array);
        }
 
+       flags[i] = NULL;
+
        service = g_list_last(local_services)->data;
 
        chrc = g_new0(struct chrc, 1);
@@ -3012,7 +3007,7 @@ static void clone_chrc(struct GDBusProxy *proxy)
        chrc->uuid = g_strdup(uuid);
        chrc->path = g_strdup_printf("%s/chrc%u", service->path,
                                        g_list_length(service->chrcs));
-       chrc->flags = flags;
+       chrc->flags = g_strdupv(flags);
 
        if (g_dbus_register_interface(service->conn, chrc->path, CHRC_INTERFACE,
                                        chrc_methods, NULL, chrc_properties,