aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorBruna Moreira <bruna.moreira@openbossa.org>2010-09-30 14:47:13 -0400
committerJohan Hedberg <johan.hedberg@nokia.com>2010-10-04 17:06:48 +0200
commit8d536ccf2b8585f6afbfdf235221aa7262974d18 (patch)
tree3b62f47a55d4eb1e72a9cfa57c6bc69ea49b87e0 /attrib/client.c
parent420d5b33139dc2883332db09c955de657ea17e00 (diff)
downloadbluez-8d536ccf2b8585f6afbfdf235221aa7262974d18.tar.gz
bluez-8d536ccf2b8585f6afbfdf235221aa7262974d18.tar.xz
bluez-8d536ccf2b8585f6afbfdf235221aa7262974d18.zip
Use g_slist_foreach() instead of a for loop
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/attrib/client.c b/attrib/client.c
index 8eabfea2..738bc07b 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -263,26 +263,23 @@ static int characteristic_set_value(struct characteristic *chr,
return 0;
}
-static void update_watchers(struct primary *prim, struct characteristic *chr)
+static void update_watchers(gpointer data, gpointer user_data)
{
- GSList *l;
-
- for (l = prim->watchers; l; l = l->next) {
- DBusMessage *msg;
- struct watcher *w = l->data;
+ struct watcher *w = data;
+ struct characteristic *chr = user_data;
+ DBusMessage *msg;
- msg = dbus_message_new_method_call(w->name, w->path,
- "org.bluez.Watcher", "ValueChanged");
- if (msg == NULL)
- return;
+ msg = dbus_message_new_method_call(w->name, w->path,
+ "org.bluez.Watcher", "ValueChanged");
+ if (msg == NULL)
+ return;
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &chr->path,
- DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
- &chr->value, chr->vlen, DBUS_TYPE_INVALID);
+ dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &chr->path,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &chr->value, chr->vlen, DBUS_TYPE_INVALID);
- dbus_message_set_no_reply(msg, TRUE);
- g_dbus_send_message(connection, msg);
- }
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(connection, msg);
}
static void events_handler(const uint8_t *pdu, uint16_t len,
@@ -322,7 +319,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len,
if (characteristic_set_value(chr, pdu + 2, len - 2) < 0)
DBG("Can't change Characteristic %0x02x", handle);
- update_watchers(prim, chr);
+ g_slist_foreach(prim->watchers, update_watchers, chr);
break;
}
}