All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/2] Fix a couple of endian issues
@ 2020-08-19 13:22 Mark Marshall
  2020-08-19 13:22 ` [PATCH BlueZ 1/2] btiotest: Correct setting of addr_type for big-endian platforms Mark Marshall
  2020-08-19 13:22 ` [PATCH BlueZ 2/2] l2test: Correct the endian handling Mark Marshall
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Marshall @ 2020-08-19 13:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mark Marshall

From: Mark Marshall <markmarshall14@gmail.com>

I'm running BlueZ on a big-endian platform, and have found a couple of
small endian issues with the tools code.

Mark Marshall (2):
  btiotest: Correct setting of addr_type for big-endian platforms
  l2test: Correct the endian handling

 tools/btiotest.c |  7 ++++---
 tools/l2test.c   | 14 +++++++-------
 2 files changed, 11 insertions(+), 10 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 1/2] btiotest: Correct setting of addr_type for big-endian platforms
  2020-08-19 13:22 [PATCH BlueZ 0/2] Fix a couple of endian issues Mark Marshall
@ 2020-08-19 13:22 ` Mark Marshall
  2020-08-19 13:50   ` [BlueZ,1/2] " bluez.test.bot
  2020-08-19 13:22 ` [PATCH BlueZ 2/2] l2test: Correct the endian handling Mark Marshall
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Marshall @ 2020-08-19 13:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mark Marshall

The glibc option parser expects the option values pointed to by
G_OPTION_ARG_INT to be an int, so a guint8 is wrong in all cases,
but on a big-endian platform you can't even change the addr_type.
(On little endian, it would appear to work).
---
 tools/btiotest.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/btiotest.c b/tools/btiotest.c
index 6c778e3c5..d56bb4fda 100644
--- a/tools/btiotest.c
+++ b/tools/btiotest.c
@@ -556,7 +556,7 @@ static int opt_sec = 0;
 static gboolean opt_master = FALSE;
 static int opt_priority = 0;
 static int opt_cid = 0;
-static guint8 opt_addr_type = 0;
+static int opt_addr_type = 0;
 
 static GMainLoop *main_loop;
 
@@ -616,8 +616,9 @@ int main(int argc, char *argv[])
 	g_option_context_free(context);
 
 	printf("accept=%d reject=%d discon=%d defer=%d sec=%d update_sec=%d"
-		" prio=%d voice=0x%04x\n", opt_accept, opt_reject, opt_disconn,
-		opt_defer, opt_sec, opt_update_sec, opt_priority, opt_voice);
+		" prio=%d voice=0x%04x addr_type=%u\n", opt_accept, opt_reject, opt_disconn,
+		opt_defer, opt_sec, opt_update_sec, opt_priority, opt_voice,
+		opt_addr_type);
 
 	if (opt_psm || opt_cid) {
 		if (argc > 1)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 2/2] l2test: Correct the endian handling
  2020-08-19 13:22 [PATCH BlueZ 0/2] Fix a couple of endian issues Mark Marshall
  2020-08-19 13:22 ` [PATCH BlueZ 1/2] btiotest: Correct setting of addr_type for big-endian platforms Mark Marshall
@ 2020-08-19 13:22 ` Mark Marshall
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Marshall @ 2020-08-19 13:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mark Marshall

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 --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");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [BlueZ,1/2] btiotest: Correct setting of addr_type for big-endian platforms
  2020-08-19 13:22 ` [PATCH BlueZ 1/2] btiotest: Correct setting of addr_type for big-endian platforms Mark Marshall
@ 2020-08-19 13:50   ` bluez.test.bot
  0 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2020-08-19 13:50 UTC (permalink / raw)
  To: linux-bluetooth, mark.marshall

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]


This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While we are preparing for reviewing the patches, we found the following
issue/warning.

Test Result:
checkpatch Failed

Outputs:
ERROR:INITIALISED_STATIC: do not initialise statics to 0
#21: FILE: tools/btiotest.c:559:
+static int opt_addr_type = 0;

WARNING:LONG_LINE: line over 80 characters
#31: FILE: tools/btiotest.c:619:
+		" prio=%d voice=0x%04x addr_type=%u\n", opt_accept, opt_reject, opt_disconn,

- total: 1 errors, 1 warnings, 19 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.



---
Regards,
Linux Bluetooth

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-19 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 13:22 [PATCH BlueZ 0/2] Fix a couple of endian issues Mark Marshall
2020-08-19 13:22 ` [PATCH BlueZ 1/2] btiotest: Correct setting of addr_type for big-endian platforms Mark Marshall
2020-08-19 13:50   ` [BlueZ,1/2] " bluez.test.bot
2020-08-19 13:22 ` [PATCH BlueZ 2/2] l2test: Correct the endian handling Mark Marshall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.