summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-09-12 18:26:33 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-09-12 18:26:33 +0000
commitb809f2edd68ddd472249998ad54e0fdaa4e51c2e (patch)
treec7c0c58d44b0412139837210d60b1b59ca791520
parentb5eb9bbc8bea09994ad3e05aabdcdff0748a17e5 (diff)
fixed uuid cmp function
-rw-r--r--hcid/dbus-rfcomm.c7
-rw-r--r--hcid/dbus-sdp.c31
2 files changed, 16 insertions, 22 deletions
diff --git a/hcid/dbus-rfcomm.c b/hcid/dbus-rfcomm.c
index 2324489c..a430a543 100644
--- a/hcid/dbus-rfcomm.c
+++ b/hcid/dbus-rfcomm.c
@@ -510,13 +510,10 @@ static sdp_record_t *get_record_from_string(const char *dst,
uint32_t handle;
/* Check if the string is a service name */
- short_uuid.value.uuid16 = sdp_str2svclass(string);
+ sdp_uuid16_create(&short_uuid, sdp_str2svclass(string));
if (short_uuid.value.uuid16) {
- short_uuid.type = SDP_UUID16;
- uuid = sdp_uuid_to_uuid128(&short_uuid);
- rec = find_record_by_uuid(dst, uuid);
- bt_free(uuid);
+ rec = find_record_by_uuid(dst, &short_uuid);
} else if (sscanf(string, "%8x-%4hx-%4hx-%4hx-%8x%4hx", &data0,
&data1, &data2, &data3, &data4, &data5) == 6) {
data0 = htonl(data0);
diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c
index 07ed7782..d4e9264f 100644
--- a/hcid/dbus-sdp.c
+++ b/hcid/dbus-sdp.c
@@ -1169,24 +1169,21 @@ search_request:
}
-static int sdp_uuid_comp_func(const void *key1, const void *key2)
-{
- const uuid_t *a = key1;
- const uuid_t *b = key2;
+static int uuid_cmp(const void *key1, const void *key2)
+{
+ uuid_t *a, *b;
+ int ret_val;
- if (a->type != b->type)
- return 1;
+ /* converting to uuid128 */
+ a = sdp_uuid_to_uuid128((uuid_t *) key1);
+ b = sdp_uuid_to_uuid128((uuid_t *) key2);
- switch (a->type) {
- case SDP_UUID16:
- return !(a->value.uuid16 == b->value.uuid16);
- case SDP_UUID32:
- return !(a->value.uuid32 == b->value.uuid32);
- case SDP_UUID128:
- return !memcmp(&a->value.uuid128, &b->value.uuid128,
- sizeof(uint128_t));
- }
- return 1;
+ ret_val = sdp_uuid128_cmp(a, b);
+
+ bt_free(a);
+ bt_free(b);
+
+ return ret_val;
}
sdp_record_t *find_record_by_uuid(const char *address, uuid_t *uuid)
@@ -1207,7 +1204,7 @@ sdp_record_t *find_record_by_uuid(const char *address, uuid_t *uuid)
if (sdp_get_service_classes(r->record, &list) != 0)
continue;
- if (sdp_list_find(list, uuid, sdp_uuid_comp_func))
+ if (sdp_list_find(list, uuid, uuid_cmp))
return r->record;
}
}