From 0634bb904ea8fdf014d173b8f142638491453775 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Sun, 11 Jun 2023 15:54:38 +0800 Subject: [PATCH] bluedroid: fixed compile warning when optimize for performance --- .../bt/host/bluedroid/api/include/api/esp_gattc_api.h | 2 +- .../bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 3 ++- components/bt/host/bluedroid/stack/gatt/gatt_sr_hash.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h index d337845b35..0cd4f312aa 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -126,7 +126,7 @@ typedef union { } search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */ /** - * @brief ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT + * @brief ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT, ESP_GATTC_READ_MULTIPLE_EVT, ESP_GATTC_READ_MULTI_VAR_EVT */ struct gattc_read_char_evt_param { diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 83d55fdb41..376a8a6fe2 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -86,7 +86,8 @@ static void btc_gap_ble_get_dev_name_callback(UINT8 status, char *name) param.get_dev_name_cmpl.status = btc_btm_status_to_esp_status(status); param.get_dev_name_cmpl.name = (char *)osi_malloc(BTC_MAX_LOC_BD_NAME_LEN + 1); if (param.get_dev_name_cmpl.name) { - BCM_STRNCPY_S(param.get_dev_name_cmpl.name, name, BTC_MAX_LOC_BD_NAME_LEN + 1); + BCM_STRNCPY_S(param.get_dev_name_cmpl.name, name, BTC_MAX_LOC_BD_NAME_LEN); + param.get_dev_name_cmpl.name[BTC_MAX_LOC_BD_NAME_LEN] = '\0'; } else { param.get_dev_name_cmpl.status = ESP_BT_STATUS_NOMEM; } diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_sr_hash.c b/components/bt/host/bluedroid/stack/gatt/gatt_sr_hash.c index 13a2fada21..79d09d7a64 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_sr_hash.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_sr_hash.c @@ -76,7 +76,7 @@ static size_t calculate_database_info_size(void) // Included service declaration len += 8 + p_attr->p_value->incl_handle.service_type.len; } else if (p_attr->uuid == GATT_UUID_CHAR_DECLARE) { - tBT_UUID char_uuid; + tBT_UUID char_uuid = {0}; // Characteristic declaration p_attr = (tGATT_ATTR16 *)p_attr->p_next; attr_uuid_to_bt_uuid((void *)p_attr, &char_uuid); @@ -126,7 +126,7 @@ static void fill_database_info(UINT8 *p_data) UINT16_TO_STREAM(p_data, p_attr->p_value->incl_handle.e_handle); gatt_build_uuid_to_stream(&p_data, p_attr->p_value->incl_handle.service_type); } else if (p_attr->uuid == GATT_UUID_CHAR_DECLARE) { - tBT_UUID char_uuid; + tBT_UUID char_uuid = {0}; // Characteristic declaration UINT16_TO_STREAM(p_data, p_attr->handle); UINT16_TO_STREAM(p_data, GATT_UUID_CHAR_DECLARE); @@ -225,7 +225,7 @@ void gatts_show_local_database(void) printf("\tend_handle %d\n", p_attr->p_value->incl_handle.e_handle); break; case GATT_UUID_CHAR_DECLARE: { - tBT_UUID char_uuid; + tBT_UUID char_uuid = {0}; tGATT_ATTR16 *p_char_val; p_char_val = (tGATT_ATTR16 *)p_attr->p_next; attr_uuid_to_bt_uuid((void *)p_char_val, &char_uuid);