diff mbox series

[BlueZ,2/2] l2test: Correct the endian handling

Message ID 411f2f20-c199-44ef-a974-8c2230e07e51@EXC04-ATKLA.omicron.at (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series Fix a couple of endian issues | expand

Commit Message

Mark Marshall Aug. 19, 2020, 1:22 p.m. UTC
The code that deals with endian issues was not always correct, use
bt_get_leN in all cases.
---
 tools/l2test.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/tools/l2test.c b/tools/l2test.c
index 0d846ed93..a62eacb4e 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -1155,8 +1155,8 @@  static void info_request(char *svr)
 
 	switch (btohs(rsp->result)) {
 	case 0x0000:
-		memcpy(&mtu, rsp->data, sizeof(mtu));
-		printf("Connectionless MTU size is %d\n", btohs(mtu));
+		mtu = bt_get_le16(rsp->data);
+		printf("Connectionless MTU size is %d\n", mtu);
 		break;
 	case 0x0001:
 		printf("Connectionless MTU is not supported\n");
@@ -1182,8 +1182,8 @@  static void info_request(char *svr)
 
 	switch (btohs(rsp->result)) {
 	case 0x0000:
-		memcpy(&mask, rsp->data, sizeof(mask));
-		printf("Extended feature mask is 0x%04x\n", btohl(mask));
+		mask = bt_get_le32(rsp->data);
+		printf("Extended feature mask is 0x%04x\n", mask);
 		if (mask & L2CAP_FEAT_FLOWCTL)
 			printf("  Flow control mode\n");
 		if (mask & L2CAP_FEAT_RETRANS)
@@ -1210,7 +1210,7 @@  static void info_request(char *svr)
 		break;
 	}
 
-	if (!(mask & 0x80))
+	if (!(mask & L2CAP_FEAT_FIXED_CHAN))
 		goto failed;
 
 	memset(buf, 0, sizeof(buf));
@@ -1232,8 +1232,8 @@  static void info_request(char *svr)
 
 	switch (btohs(rsp->result)) {
 	case 0x0000:
-		memcpy(&channels, rsp->data, sizeof(channels));
-		printf("Fixed channels list is 0x%04x\n", btohl(channels));
+		channels = bt_get_le32(rsp->data);
+		printf("Fixed channels list is 0x%04x\n", channels);
 		break;
 	case 0x0001:
 		printf("Fixed channels list is not supported\n");