summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-29 23:18:06 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-10-29 23:18:06 +0200
commit1e32e38099383b442b48d5f8b61142226269dde0 (patch)
tree25b8f914d848dde5702e4874e35dd853b2b78fab /src/device.c
parent4b1914903cb105acf843b84833e81d5470133879 (diff)
Fix duplicate UUID detection
The original code didn't work because the continue statement in the innermost for-loop was supposed to act on the outer for-loop (which it obviously doesn't do).
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/device.c b/src/device.c
index 27e0ef25..95fec822 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1107,6 +1107,26 @@ done:
search_cb(recs, err, user_data);
}
+static gboolean is_in_uuid_list(const char *uuid)
+{
+ uint16_t uuid16;
+ int j;
+
+ /* Check for Bluetooth UUID-16 */
+ if (strlen(uuid) != 36 || strncmp(uuid, "0000", 4) ||
+ strcasecmp(uuid + 8, "-0000-1000-8000-00805F9B34FB"))
+ return FALSE;
+
+ uuid16 = strtol(uuid, NULL, 16);
+
+ for (j = 0; uuid_list[j]; j++) {
+ if (uuid16 == uuid_list[j])
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void init_browse(struct browse_req *req, gboolean reverse)
{
GSList *l;
@@ -1117,21 +1137,11 @@ static void init_browse(struct browse_req *req, gboolean reverse)
for (i = 0; driver->uuids[i]; i++) {
char *uuid;
- int j;
-
- /* Eliminate duplicates of UUIDs in uuid_list[]... */
- if (strlen(driver->uuids[i]) == 36 &&
- !strncmp(driver->uuids[i], "0000", 4) &&
- !strcasecmp(driver->uuids[i] + 8,
- "-0000-1000-8000-00805F9B34FB")) {
- uint16_t uuid16 = strtol(driver->uuids[i],
- NULL, 16);
- for (j = 0; uuid_list[j]; j++) {
- if (uuid16 == uuid_list[j])
- continue;
- }
- }
+ /* Check for duplicates in our default UUID list */
+ if (is_in_uuid_list(driver->uuids[i]))
+ continue;
+
/* ... and of UUIDs another driver already asked for */
if (g_slist_find_custom(req->uuids, driver->uuids[i],
(GCompareFunc) strcasecmp))