diff mbox series

[v2,3/7] monitor: Move print_hex_field to display.h

Message ID 20220520041701.2572197-3-luiz.dentz@gmail.com
State Superseded
Headers show
Series [v2,1/7] settings: Add btd_settings_gatt_db_{store,load} | expand

Commit Message

Luiz Augusto von Dentz May 20, 2022, 4:16 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This moves print_hex_field to display.h and removes the duplicated code
from packet.c and l2cap.c.
---
 monitor/display.h | 14 ++++++++++++++
 monitor/l2cap.c   | 14 --------------
 monitor/packet.c  | 14 --------------
 3 files changed, 14 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/monitor/display.h b/monitor/display.h
index be5739833..5a82f8e6f 100644
--- a/monitor/display.h
+++ b/monitor/display.h
@@ -76,6 +76,20 @@  static inline uint64_t print_bitfield(int indent, uint64_t val,
 	return mask;
 }
 
+static inline void print_hex_field(const char *label, const uint8_t *data,
+								uint8_t len)
+{
+	char str[len * 2 + 1];
+	uint8_t i;
+
+	str[0] = '\0';
+
+	for (i = 0; i < len; i++)
+		sprintf(str + (i * 2), "%2.2x", data[i]);
+
+	print_field("%s: %s", label, str);
+}
+
 void set_default_pager_num_columns(int num_columns);
 int num_columns(void);
 
diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index 01825ce0a..192b6c920 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -2123,20 +2123,6 @@  static void amp_packet(uint16_t index, bool in, uint16_t handle,
 	opcode_data->func(&frame);
 }
 
-static void print_hex_field(const char *label, const uint8_t *data,
-								uint8_t len)
-{
-	char str[len * 2 + 1];
-	uint8_t i;
-
-	str[0] = '\0';
-
-	for (i = 0; i < len; i++)
-		sprintf(str + (i * 2), "%2.2x", data[i]);
-
-	print_field("%s: %s", label, str);
-}
-
 static void print_uuid(const char *label, const void *data, uint16_t size)
 {
 	const char *str;
diff --git a/monitor/packet.c b/monitor/packet.c
index d80735a06..2e02b3923 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -1755,20 +1755,6 @@  static void print_key_size(uint8_t key_size)
 	print_field("Key size: %d", key_size);
 }
 
-static void print_hex_field(const char *label, const uint8_t *data,
-								uint8_t len)
-{
-	char str[len * 2 + 1];
-	uint8_t i;
-
-	str[0] = '\0';
-
-	for (i = 0; i < len; i++)
-		sprintf(str + (i * 2), "%2.2x", data[i]);
-
-	print_field("%s: %s", label, str);
-}
-
 static void print_key(const char *label, const uint8_t *link_key)
 {
 	print_hex_field(label, link_key, 16);