Diff between 1c58c18eaaebce43528617fdd439a4ccf56e1496 and 2854ecff1ffa1af743e9df8e3fe4cef68750c964

Changed Files

File Additions Deletions Status
lib/bluetooth.c +6 -12 modified

Full Patch

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index a1b4c13..72ee456 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -63,21 +63,15 @@ char *batostr(const bdaddr_t *ba)
 
 bdaddr_t *strtoba(const char *str)
 {
-	const char *ptr = str;
-	int i;
-
-	uint8_t *ba = bt_malloc(sizeof(bdaddr_t));
-	if (!ba)
-		return NULL;
+	bdaddr_t b;
+	bdaddr_t *ba = bt_malloc(sizeof(*ba));
 
-	for (i = 0; i < 6; i++) {
-		ba[i] = (uint8_t) strtol(ptr, NULL, 16);
-		if (i != 5 && !(ptr = strchr(ptr,':')))
-			ptr = ":00:00:00:00:00";
-		ptr++;
+	if (ba) {
+		str2ba(str, &b);
+		baswap(ba, &b);
 	}
 
-	return (bdaddr_t *) ba;
+	return ba;
 }
 
 int ba2str(const bdaddr_t *ba, char *str)