diff mbox series

[BlueZ] bthost: Add bthost_debug and use it on smp.c

Message ID 20210813005739.1043743-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [BlueZ] bthost: Add bthost_debug and use it on smp.c | expand

Commit Message

Luiz Augusto von Dentz Aug. 13, 2021, 12:57 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds bthost_debug which wraps util_debug and make use of it in
smp.c.
---
 emulator/bthost.c | 50 +++++++++++++++++++++++++----------------------
 emulator/bthost.h |  2 ++
 emulator/hciemu.c |  4 ++--
 emulator/smp.c    | 20 ++++++++++++++-----
 4 files changed, 46 insertions(+), 30 deletions(-)

Comments

bluez.test.bot@gmail.com Aug. 13, 2021, 1:23 a.m. UTC | #1
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.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=530891

---Test result---

Test Summary:
CheckPatch                    FAIL      0.34 seconds
GitLint                       PASS      0.10 seconds
Prep - Setup ELL              PASS      40.10 seconds
Build - Prep                  PASS      0.10 seconds
Build - Configure             PASS      7.08 seconds
Build - Make                  PASS      175.43 seconds
Make Check                    PASS      9.31 seconds
Make Distcheck                PASS      209.33 seconds
Build w/ext ELL - Configure   PASS      7.18 seconds
Build w/ext ELL - Make        PASS      165.35 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
bthost: Add bthost_debug and use it on smp.c
WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __printf(2, 3) over __attribute__((format(printf, 2, 3)))
#163: FILE: emulator/bthost.h:31:
+					__attribute__((format(printf, 2, 3)));

- total: 0 errors, 1 warnings, 210 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.

"[PATCH] bthost: Add bthost_debug and use it on smp.c" has style problems, please review.

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

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


##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Aug. 13, 2021, 9:04 p.m. UTC | #2
Hi,

On Thu, Aug 12, 2021 at 6:23 PM <bluez.test.bot@gmail.com> wrote:
>
> 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.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=530891
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    FAIL      0.34 seconds
> GitLint                       PASS      0.10 seconds
> Prep - Setup ELL              PASS      40.10 seconds
> Build - Prep                  PASS      0.10 seconds
> Build - Configure             PASS      7.08 seconds
> Build - Make                  PASS      175.43 seconds
> Make Check                    PASS      9.31 seconds
> Make Distcheck                PASS      209.33 seconds
> Build w/ext ELL - Configure   PASS      7.18 seconds
> Build w/ext ELL - Make        PASS      165.35 seconds
>
> Details
> ##############################
> Test: CheckPatch - FAIL
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
> Output:
> bthost: Add bthost_debug and use it on smp.c
> WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __printf(2, 3) over __attribute__((format(printf, 2, 3)))
> #163: FILE: emulator/bthost.h:31:
> +                                       __attribute__((format(printf, 2, 3)));
>
> - total: 0 errors, 1 warnings, 210 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.
>
> "[PATCH] bthost: Add bthost_debug and use it on smp.c" has style problems, please review.
>
> NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
>
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
>
>
> ##############################
> Test: GitLint - PASS
> Desc: Run gitlint with rule in .gitlint
>
> ##############################
> Test: Prep - Setup ELL - PASS
> Desc: Clone, build, and install ELL
>
> ##############################
> Test: Build - Prep - PASS
> Desc: Prepare environment for build
>
> ##############################
> Test: Build - Configure - PASS
> Desc: Configure the BlueZ source tree
>
> ##############################
> Test: Build - Make - PASS
> Desc: Build the BlueZ source tree
>
> ##############################
> Test: Make Check - PASS
> Desc: Run 'make check'
>
> ##############################
> Test: Make Distcheck - PASS
> Desc: Run distcheck to check the distribution
>
> ##############################
> Test: Build w/ext ELL - Configure - PASS
> Desc: Configure BlueZ source with '--enable-external-ell' configuration
>
> ##############################
> Test: Build w/ext ELL - Make - PASS
> Desc: Build BlueZ source with '--enable-external-ell' configuration
>
>
>
> ---
> Regards,
> Linux Bluetooth

Pushed.
diff mbox series

Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 62f5a1bae..547685208 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -691,8 +691,7 @@  static void send_command(struct bthost *bthost, uint16_t opcode,
 	uint8_t pkt = BT_H4_CMD_PKT;
 	struct iovec iov[3];
 
-	util_debug(bthost->debug_callback, bthost->debug_data,
-				"command 0x%02x", opcode);
+	bthost_debug(bthost, "command 0x%02x", opcode);
 
 	iov[0].iov_base = &pkt;
 	iov[0].iov_len = sizeof(pkt);
@@ -794,6 +793,18 @@  bool bthost_set_debug(struct bthost *bthost, bthost_debug_func_t callback,
 	return true;
 }
 
+void bthost_debug(struct bthost *host, const char *format, ...)
+{
+	va_list ap;
+
+	if (!host || !format || !host->debug_callback)
+		return;
+
+	va_start(ap, format);
+	util_debug_va(host->debug_callback, host->debug_data, format, ap);
+	va_end(ap);
+}
+
 static void read_local_features_complete(struct bthost *bthost,
 						const void *data, uint8_t len)
 {
@@ -870,8 +881,8 @@  static void evt_cmd_complete(struct bthost *bthost, const void *data,
 	case BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE:
 		break;
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"Unhandled cmd_complete opcode 0x%04x", opcode);
+		bthost_debug(bthost, "Unhandled cmd_complete opcode 0x%04x",
+								opcode);
 		break;
 	}
 
@@ -1298,8 +1309,7 @@  static void evt_le_meta_event(struct bthost *bthost, const void *data,
 	if (len < 1)
 		return;
 
-	util_debug(bthost->debug_callback, bthost->debug_data,
-				"event 0x%02x", *event);
+	bthost_debug(bthost, "event 0x%02x", *event);
 
 	switch (*event) {
 	case BT_HCI_EVT_LE_CONN_COMPLETE:
@@ -1321,8 +1331,8 @@  static void evt_le_meta_event(struct bthost *bthost, const void *data,
 		evt_le_cis_req(bthost, evt_data, len - 1);
 		break;
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"Unsupported LE Meta event 0x%2.2x", *event);
+		bthost_debug(bthost, "Unsupported LE Meta event 0x%2.2x",
+								*event);
 		break;
 	}
 }
@@ -1340,8 +1350,7 @@  static void process_evt(struct bthost *bthost, const void *data, uint16_t len)
 
 	param = data + sizeof(*hdr);
 
-	util_debug(bthost->debug_callback, bthost->debug_data,
-				"event 0x%02x", hdr->evt);
+	bthost_debug(bthost, "event 0x%02x", hdr->evt);
 
 	switch (hdr->evt) {
 	case BT_HCI_EVT_CMD_COMPLETE:
@@ -1409,8 +1418,7 @@  static void process_evt(struct bthost *bthost, const void *data, uint16_t len)
 		break;
 
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"Unsupported event 0x%2.2x", hdr->evt);
+		bthost_debug(bthost, "Unsupported event 0x%2.2x", hdr->evt);
 		break;
 	}
 }
@@ -1754,8 +1762,7 @@  static void l2cap_sig(struct bthost *bthost, struct btconn *conn,
 		break;
 
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"Unknown L2CAP code 0x%02x", hdr->code);
+		bthost_debug(bthost, "Unknown L2CAP code 0x%02x", hdr->code);
 		ret = false;
 	}
 
@@ -1987,8 +1994,7 @@  static void l2cap_le_sig(struct bthost *bthost, struct btconn *conn,
 		break;
 
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"Unknown L2CAP code 0x%02x", hdr->code);
+		bthost_debug(bthost, "Unknown L2CAP code 0x%02x", hdr->code);
 		ret = false;
 	}
 
@@ -2329,8 +2335,7 @@  static void process_rfcomm(struct bthost *bthost, struct btconn *conn,
 		rfcomm_uih_recv(bthost, conn, l2conn, data, len);
 		break;
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-					"Unknown frame type");
+		bthost_debug(bthost, "Unknown frame type");
 		break;
 	}
 }
@@ -2355,8 +2360,8 @@  static void process_acl(struct bthost *bthost, const void *data, uint16_t len)
 	handle = acl_handle(acl_hdr->handle);
 	conn = bthost_find_conn(bthost, handle);
 	if (!conn) {
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"ACL data for unknown handle 0x%04x", handle);
+		bthost_debug(bthost, "ACL data for unknown handle 0x%04x",
+								handle);
 		return;
 	}
 
@@ -2392,7 +2397,7 @@  static void process_acl(struct bthost *bthost, const void *data, uint16_t len)
 		if (l2conn && l2conn->psm == 0x0003)
 			process_rfcomm(bthost, conn, l2conn, l2_data, l2_len);
 		else
-			util_debug(bthost->debug_callback, bthost->debug_data,
+			bthost_debug(bthost,
 					"Packet for unknown CID 0x%04x (%u)",
 					cid, cid);
 		break;
@@ -2422,8 +2427,7 @@  void bthost_receive_h4(struct bthost *bthost, const void *data, uint16_t len)
 		process_acl(bthost, data + 1, len - 1);
 		break;
 	default:
-		util_debug(bthost->debug_callback, bthost->debug_data,
-				"Unsupported packet 0x%2.2x", pkt_type);
+		bthost_debug(bthost, "Unsupported packet 0x%2.2x", pkt_type);
 		break;
 	}
 }
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 5a85b7232..3dec44514 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -27,6 +27,8 @@  typedef void (*bthost_debug_func_t)(const char *str, void *user_data);
 typedef void (*bthost_destroy_func_t)(void *user_data);
 bool bthost_set_debug(struct bthost *bthost, bthost_debug_func_t callback,
 			void *user_data, bthost_destroy_func_t destroy);
+void bthost_debug(struct bthost *bthost, const char *format, ...)
+					__attribute__((format(printf, 2, 3)));
 
 void bthost_set_send_handler(struct bthost *bthost, bthost_send_func handler,
 							void *user_data);
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index a3ec44243..fe5ef747a 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -454,7 +454,7 @@  void hciemu_unref(struct hciemu *hciemu)
 	free(hciemu);
 }
 
-static void bthost_debug(const char *str, void *user_data)
+static void bthost_print(const char *str, void *user_data)
 {
 	struct hciemu *hciemu = user_data;
 
@@ -484,7 +484,7 @@  static void hciemu_client_set_debug(void *data, void *user_data)
 	struct hciemu *hciemu = user_data;
 
 	btdev_set_debug(client->dev, btdev_client_debug, hciemu, NULL);
-	bthost_set_debug(client->host, bthost_debug, hciemu, NULL);
+	bthost_set_debug(client->host, bthost_print, hciemu, NULL);
 }
 
 bool hciemu_set_debug(struct hciemu *hciemu, hciemu_debug_func_t callback,
diff --git a/emulator/smp.c b/emulator/smp.c
index ec1baea04..21a34dde6 100644
--- a/emulator/smp.c
+++ b/emulator/smp.c
@@ -358,7 +358,8 @@  static bool verify_random(struct smp_conn *conn, const uint8_t rnd[16])
 		return false;
 
 	if (memcmp(conn->pcnf, confirm, sizeof(conn->pcnf)) != 0) {
-		printf("Confirmation values don't match\n");
+		bthost_debug(conn->smp->bthost,
+					"Confirmation values don't match");
 		return false;
 	}
 
@@ -698,12 +699,13 @@  void smp_data(void *conn_data, const void *data, uint16_t len)
 	uint8_t opcode;
 
 	if (len < 1) {
-		printf("Received too small SMP PDU\n");
+		bthost_debug(conn->smp->bthost, "Received too small SMP PDU");
 		return;
 	}
 
 	if (conn->addr_type == BDADDR_BREDR) {
-		printf("Received BR/EDR SMP data on LE link\n");
+		bthost_debug(conn->smp->bthost,
+					"Received BR/EDR SMP data on LE link");
 		return;
 	}
 
@@ -754,12 +756,13 @@  void smp_bredr_data(void *conn_data, const void *data, uint16_t len)
 	uint8_t opcode;
 
 	if (len < 1) {
-		printf("Received too small SMP PDU\n");
+		bthost_debug(conn->smp->bthost, "Received too small SMP PDU");
 		return;
 	}
 
 	if (conn->addr_type != BDADDR_BREDR) {
-		printf("Received LE SMP data on BR/EDR link\n");
+		bthost_debug(conn->smp->bthost,
+					"Received LE SMP data on BR/EDR link");
 		return;
 	}
 
@@ -853,6 +856,7 @@  void *smp_conn_add(void *smp_data, uint16_t handle,
 {
 	struct smp *smp = smp_data;
 	struct smp_conn *conn;
+	char ia_str[18], ra_str[18];
 
 	conn = malloc(sizeof(struct smp_conn));
 	if (!conn)
@@ -870,6 +874,12 @@  void *smp_conn_add(void *smp_data, uint16_t handle,
 	memcpy(conn->ia, ia, 6);
 	memcpy(conn->ra, ra, 6);
 
+	ba2str((bdaddr_t *) ia, ia_str);
+	ba2str((bdaddr_t *) ra, ra_str);
+
+	bthost_debug(smp->bthost, "ia %s type 0x%02x ra %s type 0x%02x",
+					ia_str, ia_type, ra_str, ra_type);
+
 	bt_crypto_random_bytes(smp->crypto, conn->prnd, sizeof(conn->prnd));
 
 	return conn;