From 5f83e8dee7f16680ba3317dc77c86273d96b2b49 Mon Sep 17 00:00:00 2001 From: fangzhenwei Date: Mon, 13 Jan 2025 16:20:26 +0800 Subject: [PATCH] addr: fix bt_addr_str multiple define bug: v/49964 Signed-off-by: fangzhenwei --- framework/common/bt_addr.c | 12 +++++++----- framework/include/bt_addr.h | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/framework/common/bt_addr.c b/framework/common/bt_addr.c index fe89f0d..aadd537 100644 --- a/framework/common/bt_addr.c +++ b/framework/common/bt_addr.c @@ -21,12 +21,14 @@ #include "bt_addr.h" -const bt_address_t bt_addr_empty = { +static const bt_address_t bt_addr_empty = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; -const bt_address_t bt_addr_any = { - { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } -}; + +/* remove this unused variable */ +// const bt_address_t bt_addr_any = { +// { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } +// }; static char g_bdaddr_str[18]; @@ -79,7 +81,7 @@ int bt_addr_ba2str(const bt_address_t* addr, char* str) addr->addr[2], addr->addr[1], addr->addr[0]); } -char* bt_addr_str(const bt_address_t* addr) +char* bt_addr_bastr(const bt_address_t* addr) { if (!addr) { return NULL; diff --git a/framework/include/bt_addr.h b/framework/include/bt_addr.h index 287cff6..8240789 100644 --- a/framework/include/bt_addr.h +++ b/framework/include/bt_addr.h @@ -162,11 +162,12 @@ int bt_addr_str2ba(const char* str, bt_address_t* addr); * **Example:** * @code * bt_address_t addr = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; - * printf("Address: %s\n", bt_addr_str(&addr)); + * printf("Address: %s\n", bt_addr_bastr(&addr)); * // Output: Address: 00:11:22:33:44:55 * @endcode */ -char* bt_addr_str(const bt_address_t* addr); +char* bt_addr_bastr(const bt_address_t* addr); +#define bt_addr_str(addr) bt_addr_bastr(addr) /**