Thread (22 messages) 22 messages, 3 authors, 2012-09-05

[RFC v4 14/18] mgmt: Use bt_get_* helper functions to access unaligned memory

flat view
STALE5163d

From: Szymon Janc <hidden>
Date: 2012-09-04 14:41:33
Subsystem: the rest · Maintainer: Linus Torvalds

Revision v4 of 3 in this series.

Revisions (3)
  1. rfc [diff vs current]
  2. v2 [diff vs current]
  3. v4 current
---
 src/mgmt.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/mgmt.c b/src/mgmt.c
index 45a5c90..c64eb68 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -100,7 +100,7 @@ static void read_version_complete(int sk, void *buf, size_t len)
 		abort();
 	}
 
-	mgmt_revision = btohs(bt_get_unaligned(&rp->revision));
+	mgmt_revision = bt_get_le16(&rp->revision);
 	mgmt_version = rp->version;
 
 	DBG("version %u revision %u", mgmt_version, mgmt_revision);
@@ -923,7 +923,7 @@ static void read_index_list_complete(int sk, void *buf, size_t len)
 		return;
 	}
 
-	num = btohs(bt_get_unaligned(&rp->num_controllers));
+	num = bt_get_le16(&rp->num_controllers);
 
 	if (num * sizeof(uint16_t) + sizeof(*rp) != len) {
 		error("Incorrect packet size for index list event");
@@ -933,7 +933,7 @@ static void read_index_list_complete(int sk, void *buf, size_t len)
 	for (i = 0; i < num; i++) {
 		uint16_t index;
 
-		index = btohs(bt_get_unaligned(&rp->index[i]));
+		index = bt_get_le16(&rp->index);
 
 		add_controller(index);
 		read_info(sk, index);
@@ -1033,7 +1033,7 @@ static void read_info_complete(int sk, uint16_t index, void *buf, size_t len)
 
 	bacpy(&info->bdaddr, &rp->bdaddr);
 	info->version = rp->version;
-	info->manufacturer = btohs(bt_get_unaligned(&rp->manufacturer));
+	info->manufacturer = bt_get_le16(&rp->manufacturer);
 
 	memcpy(&info->supported_settings, &rp->supported_settings,
 					sizeof(info->supported_settings));
@@ -1365,7 +1365,7 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 		return;
 	}
 
-	opcode = btohs(bt_get_unaligned(&ev->opcode));
+	opcode = bt_get_le16(&ev->opcode);
 
 	len -= sizeof(*ev);
 
@@ -1498,7 +1498,7 @@ static void mgmt_cmd_status(int sk, uint16_t index, void *buf, size_t len)
 		return;
 	}
 
-	opcode = btohs(bt_get_unaligned(&ev->opcode));
+	opcode = bt_get_le16(&ev->opcode);
 
 	if (!ev->status) {
 		DBG("%s (0x%04x) cmd_status %u", mgmt_opstr(opcode), opcode,
@@ -1824,9 +1824,9 @@ static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data
 		return TRUE;
 	}
 
-	opcode = btohs(bt_get_unaligned(&hdr->opcode));
-	len = btohs(bt_get_unaligned(&hdr->len));
-	index = btohs(bt_get_unaligned(&hdr->index));
+	opcode = bt_get_le16(&hdr->opcode);
+	len = bt_get_le16(&hdr->len);
+	index = bt_get_le16(&hdr->index);
 
 	if (ret != MGMT_HDR_SIZE + len) {
 		error("Packet length mismatch. ret %zd len %u", ret, len);
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help