From bbfaae247fd6516e23d14d2bd573bcae02a40534 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 26 Feb 2019 19:24:40 +0200 Subject: [PATCH] client: Fix build with older version on libdbus 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' --- client/gatt.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/client/gatt.c b/client/gatt.c index e68939f96..e03ef9679 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -2959,7 +2959,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) @@ -2970,21 +2970,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); @@ -2993,7 +2988,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, -- 2.47.3