Skip to contentSkip to conversation

lib/uuid: Fix bt_uuid_strcmp

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages Sep 4, 2015 – Sep 6, 2015

Subsystems (3)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 lib/uuid: Fix bt_uuid_strcmp

From: Luiz Augusto von Dentz <[email protected]>

bt_uuid_strcmp shall first convert the strings to bt_uuid_t using bt_string_to_uuid since bt_uuid_to_string can produce different formats depending on the type.

---
 lib/uuid.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/uuid.c +6 -1
index fd61968..046b521 100644
@@ -289,7 +289,12 @@ int bt_string_to_uuid(bt_uuid_t *uuid, const char *string)
 
 int bt_uuid_strcmp(const void *a, const void *b)
 {
-	return strcasecmp(a, b);
+	bt_uuid_t u1, u2;
+
+	bt_string_to_uuid(&u1, a);
+	bt_string_to_uuid(&u2, b);
+
+	return bt_uuid_cmp(&u1, &u2);
 }
 
 int bt_uuid_to_le(const bt_uuid_t *src, void *dst)
Signature · 1 line
2.4.3
author maintainer Applied
#1 lore raw

Hi,

Quoted 28 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

bt_uuid_strcmp shall first convert the strings to bt_uuid_t using bt_string_to_uuid since bt_uuid_to_string can produce different formats depending on the type.

---
 lib/uuid.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/uuid.c +6 -2
index fd61968..046b521 100644
@@ -289,7 +289,12 @@ int bt_string_to_uuid(bt_uuid_t *uuid, const char *string)
 
 int bt_uuid_strcmp(const void *a, const void *b)
 {
-       return strcasecmp(a, b);
+       bt_uuid_t u1, u2;
+
+       bt_string_to_uuid(&u1, a);
+       bt_string_to_uuid(&u2, b);
+
+       return bt_uuid_cmp(&u1, &u2);
 }
 
 int bt_uuid_to_le(const bt_uuid_t *src, void *dst)
--
Quoted 1 line

2.4.3

Applied.

Signature · 1 line
Luiz Augusto von Dentz