OSDN Git Service

android/bluetooth: Fix compare function when finding devices
authorSzymon Janc <szymon.janc@gmail.com>
Sun, 12 Jan 2014 17:45:24 +0000 (18:45 +0100)
committerSzymon Janc <szymon.janc@gmail.com>
Sun, 12 Jan 2014 19:43:15 +0000 (20:43 +0100)
Elements on list are struct device not bdaddr_t so make comparing
function use proper types. This was working so far only due to
bdaddr_t being first element in struct device.

android/bluetooth.c

index d71e81f..f1e5458 100644 (file)
@@ -270,19 +270,19 @@ done:
        g_strfreev(uuids);
 }
 
-static int bdaddr_cmp(gconstpointer a, gconstpointer b)
+static int device_match(gconstpointer a, gconstpointer b)
 {
-       const bdaddr_t *bda = a;
-       const bdaddr_t *bdb = b;
+       const struct device *dev = a;
+       const bdaddr_t *bdaddr = b;
 
-       return bacmp(bdb, bda);
+       return bacmp(&dev->bdaddr, bdaddr);
 }
 
 static struct device *find_device(const bdaddr_t *bdaddr)
 {
        GSList *l;
 
-       l = g_slist_find_custom(devices, bdaddr, bdaddr_cmp);
+       l = g_slist_find_custom(devices, bdaddr, device_match);
        if (l)
                return l->data;