From ff49f989a74e6b747fc0dd44327c5d4d2fbc84fd Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Wed, 25 Mar 2026 13:58:40 +0800 Subject: [PATCH] fix(ble/bluedroid): Align config, controller indent and init error paths - bt_target: remove/align obsolete macros with Kconfig - device/controller: fix start_up() Secure Connections indent, get_ble_resolving_list_max_size return type - controller.h: align type/interface declarations with implementation - bte_init: remove unused/redundant code - bte_main: return -1 on osi_init failure, null check in bte_main_hci_send (cherry picked from commit b83647f5ea1034b943fd542622dc80363130418a) Co-authored-by: zhiweijian --- .../host/bluedroid/common/include/common/bt_target.h | 4 ---- components/bt/host/bluedroid/device/controller.c | 2 +- .../host/bluedroid/device/include/device/controller.h | 2 +- components/bt/host/bluedroid/main/bte_init.c | 6 ------ components/bt/host/bluedroid/main/bte_main.c | 10 +++++++++- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index 32eb642b3b..f895ef4bb3 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -618,10 +618,6 @@ #define BTA_DM_QOS_INCLUDED FALSE #endif -#ifndef BTA_PAN_INCLUDED -#define BTA_PAN_INCLUDED FALSE -#endif - #ifndef BTA_HD_INCLUDED #define BTA_HD_INCLUDED FALSE #endif diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index ac0bf4dc16..d090c7b33f 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -546,7 +546,7 @@ static uint8_t get_ble_resolving_list_max_size(void) return controller_param.ble_resolving_list_max_size; } -static void set_ble_resolving_list_max_size(int resolving_list_max_size) +static void set_ble_resolving_list_max_size(uint8_t resolving_list_max_size) { assert(controller_param.readable); assert(controller_param.ble_supported); diff --git a/components/bt/host/bluedroid/device/include/device/controller.h b/components/bt/host/bluedroid/device/include/device/controller.h index 6345d7a9c9..610c9afafc 100644 --- a/components/bt/host/bluedroid/device/include/device/controller.h +++ b/components/bt/host/bluedroid/device/include/device/controller.h @@ -78,7 +78,7 @@ typedef struct controller_t { uint8_t (*get_ble_white_list_size)(void); uint8_t (*get_ble_resolving_list_max_size)(void); - void (*set_ble_resolving_list_max_size)(int resolving_list_max_size); + void (*set_ble_resolving_list_max_size)(uint8_t resolving_list_max_size); #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE) diff --git a/components/bt/host/bluedroid/main/bte_init.c b/components/bt/host/bluedroid/main/bte_init.c index f0d209426a..c29d79ec22 100644 --- a/components/bt/host/bluedroid/main/bte_init.c +++ b/components/bt/host/bluedroid/main/bte_init.c @@ -442,9 +442,6 @@ bt_status_t BTE_InitStack(void) } memset((void *)bta_jv_cb_ptr, 0, sizeof(tBTA_JV_CB)); #endif //JV -#if BTA_HS_INCLUDED == TRUE - memset((void *)bta_hs_cb_ptr, 0, sizeof(tBTA_HS_CB)); -#endif #if BTA_SDP_INCLUDED == TRUE if ((bta_sdp_cb_ptr = (tBTA_SDP_CB *)osi_malloc(sizeof(tBTA_SDP_CB))) == NULL) { goto error_exit; @@ -486,9 +483,6 @@ bt_status_t BTE_InitStack(void) } memset((void *)bta_hd_cb_ptr, 0, sizeof(tBTA_HD_CB)); #endif -#if BTA_HL_INCLUDED==TRUE - memset((void *)bta_hl_cb_ptr, 0, sizeof(tBTA_HL_CB)); -#endif #if GATTC_INCLUDED==TRUE if ((bta_gattc_cb_ptr = (tBTA_GATTC_CB *)osi_malloc(sizeof(tBTA_GATTC_CB))) == NULL) { goto error_exit; diff --git a/components/bt/host/bluedroid/main/bte_main.c b/components/bt/host/bluedroid/main/bte_main.c index 73cbafc644..d50544ced4 100644 --- a/components/bt/host/bluedroid/main/bte_main.c +++ b/components/bt/host/bluedroid/main/bte_main.c @@ -86,7 +86,10 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb) bluedroid_init_done_cb = cb; - osi_init(); + if (osi_init() != 0) { + APPL_TRACE_ERROR("%s failed to initialize OS layer.\n", __func__); + return -1; + } //Enable HCI bte_main_enable(); @@ -235,6 +238,11 @@ void bte_main_lpm_wake_bt_device(void) ******************************************************************************/ void bte_main_hci_send (BT_HDR *p_msg, UINT16 event) { + if (!p_msg) { + APPL_TRACE_ERROR("%s null message\n", __func__); + return; + } + UINT16 sub_event = event & BT_SUB_EVT_MASK; /* local controller ID */ p_msg->event = event;