[PATCH 4/4] Make strtoba use str2ba for string conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 lib/bluetooth.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index d943fdc..aac9bdc 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)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux