diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c index a2fcfd9c72c..017164a7c2a 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c @@ -494,7 +494,7 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr arg.set_fast_prov_info.iv_index = fast_prov_info->iv_index; arg.set_fast_prov_info.offset = fast_prov_info->offset; arg.set_fast_prov_info.match_len = fast_prov_info->match_len; - if (fast_prov_info->match_len && fast_prov_info->match_val) { + if (fast_prov_info->match_len) { memcpy(arg.set_fast_prov_info.match_val, fast_prov_info->match_val, fast_prov_info->match_len); } return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL) diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c index 8fba9e9fedb..01d0ece0109 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c @@ -50,7 +50,7 @@ static void btc_ble_mesh_ble_free_req_data(btc_msg_t *msg) #if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN esp_ble_mesh_ble_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -116,7 +116,7 @@ void btc_ble_mesh_ble_call_handler(btc_msg_t *msg) esp_ble_mesh_ble_cb_param_t param = {0}; btc_ble_mesh_ble_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 08b2b7a4dde..1057d867faf 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -87,7 +87,7 @@ void btc_ble_mesh_config_client_arg_deep_free(btc_msg_t *msg) { btc_ble_mesh_config_client_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -232,7 +232,7 @@ static void btc_ble_mesh_config_client_free_req_data(btc_msg_t *msg) { esp_ble_mesh_cfg_client_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -618,7 +618,7 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) btc_ble_mesh_config_client_args_t *arg = NULL; esp_ble_mesh_cfg_client_cb_param_t cb = {0}; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -656,7 +656,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg) { esp_ble_mesh_cfg_client_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -748,7 +748,7 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg) { esp_ble_mesh_cfg_server_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index 760c6e5c649..ea64584b19d 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -111,7 +111,7 @@ void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg) { btc_ble_mesh_generic_client_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -295,7 +295,7 @@ static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg) { esp_ble_mesh_generic_client_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -447,7 +447,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) esp_ble_mesh_generic_client_cb_param_t cb = {0}; bt_mesh_client_common_param_t common = {0}; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -507,7 +507,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg) { esp_ble_mesh_generic_client_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -629,7 +629,7 @@ static void btc_ble_mesh_generic_server_free_req_data(btc_msg_t *msg) { esp_ble_mesh_generic_server_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -738,7 +738,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg) { esp_ble_mesh_generic_server_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index 2a84fea6296..8be7fdee362 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -551,7 +551,7 @@ void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg) esp_ble_mesh_health_server_cb_param_t param = {0}; btc_ble_mesh_health_server_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -577,7 +577,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg) { esp_ble_mesh_health_server_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index c5412eb802b..8c96ef82869 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -452,7 +452,7 @@ static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg) { esp_ble_mesh_lighting_server_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -553,7 +553,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg) { esp_ble_mesh_lighting_server_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index dfeaddb002d..59be9f5d873 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -124,7 +124,7 @@ void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg) { btc_ble_mesh_prov_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -200,7 +200,7 @@ void btc_ble_mesh_model_arg_deep_free(btc_msg_t *msg) { btc_ble_mesh_model_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -309,7 +309,7 @@ static void btc_ble_mesh_model_free_req_data(btc_msg_t *msg) { esp_ble_mesh_model_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -2278,9 +2278,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) /* Callback operation completion events */ btc_ble_mesh_prov_set_complete_cb(¶m, act); - if (msg->arg) { - btc_ble_mesh_prov_arg_deep_free(msg); - } + btc_ble_mesh_prov_arg_deep_free(msg); return; } @@ -2307,7 +2305,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) btc_ble_mesh_model_args_t *arg = NULL; int err = 0; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -2403,7 +2401,7 @@ void btc_ble_mesh_model_cb_handler(btc_msg_t *msg) { esp_ble_mesh_model_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index 4c6007fa641..d0df2febdab 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -179,7 +179,7 @@ void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg) { btc_ble_mesh_sensor_client_args_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -378,7 +378,7 @@ static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg) { esp_ble_mesh_sensor_client_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -529,7 +529,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) esp_ble_mesh_sensor_client_cb_param_t cb = {0}; bt_mesh_client_common_param_t common = {0}; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -589,7 +589,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg) { esp_ble_mesh_sensor_client_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -761,7 +761,7 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg) { esp_ble_mesh_sensor_server_cb_param_t *arg = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -870,7 +870,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg) { esp_ble_mesh_sensor_server_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 0c5503ab7d3..dde61d41386 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -456,7 +456,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg) { esp_ble_mesh_time_scene_server_cb_param_t *param = NULL; - if (!msg || !msg->arg) { + if (!msg) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c index 5320f667117..ca2538696d3 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c @@ -699,7 +699,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) cb_data.req_data.data_len = 0; cb_data.req_data.handle = p_msg->api_indicate.attr_id; - if (p_msg->api_indicate.value && (p_msg->api_indicate.len > 0)) { + if (p_msg->api_indicate.len > 0) { cb_data.req_data.value = (uint8_t *) osi_malloc(p_msg->api_indicate.len); if (cb_data.req_data.value != NULL) { memset(cb_data.req_data.value, 0, p_msg->api_indicate.len); @@ -709,9 +709,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) APPL_TRACE_ERROR("%s, malloc failed", __func__); } } else { - if (p_msg->api_indicate.value) { - APPL_TRACE_ERROR("%s, incorrect length", __func__); - } + APPL_TRACE_ERROR("%s, incorrect length", __func__); } (*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data); if (cb_data.req_data.value != NULL) { diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c index 4f254c605f7..e42c590cd4d 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c @@ -1472,10 +1472,10 @@ void btc_hf_cb_handler(btc_msg_t *msg) case BTA_AG_AT_D_EVT: { do { - if (event == BTA_AG_AT_D_EVT && p_data->val.str) { // dial_number_or_memory + if (event == BTA_AG_AT_D_EVT) { // dial_number_or_memory memset(¶m, 0, sizeof(esp_hf_cb_param_t)); param.out_call.num_or_loc = osi_malloc((strlen(p_data->val.str) + 1) * sizeof(char)); - sprintf(param.out_call.num_or_loc, p_data->val.str); + sprintf(param.out_call.num_or_loc, "%s", p_data->val.str); btc_hf_cb_to_app(ESP_HF_DIAL_EVT, ¶m); send_indicator_update(BTA_AG_IND_CALLSETUP,BTA_AG_CALLSETUP_OUTGOING); osi_free(param.out_call.num_or_loc); diff --git a/components/bt/host/bluedroid/stack/smp/smp_l2c.c b/components/bt/host/bluedroid/stack/smp/smp_l2c.c index 67dd1ac5ae8..a6f0670598e 100644 --- a/components/bt/host/bluedroid/stack/smp/smp_l2c.c +++ b/components/bt/host/bluedroid/stack/smp/smp_l2c.c @@ -111,7 +111,7 @@ static void smp_connect_callback (UINT16 channel, BD_ADDR bd_addr, BOOLEAN conne if (transport == BT_TRANSPORT_BR_EDR || memcmp(bd_addr, dummy_bda, BD_ADDR_LEN) == 0) { return; } - if(!connected && &p_cb->rsp_timer_ent) { + if(!connected) { //free timer btu_free_timer(&p_cb->rsp_timer_ent); } diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_discovery/README.md b/examples/bluetooth/bluedroid/classic_bt/bt_discovery/README.md index df62b407170..663337986cc 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_discovery/README.md +++ b/examples/bluetooth/bluedroid/classic_bt/bt_discovery/README.md @@ -219,7 +219,7 @@ for (int i = 0; i < param->disc_res.num_prop; i++) { Pay attention that some Bluetooth devices may put their name in EIR data. We can get the device name from EIR data. ```c -if (p_dev->eir && p_dev->bdname_len == 0) { +if (p_dev->bdname_len == 0) { get_name_from_eir(p_dev->eir, p_dev->bdname, &p_dev->bdname_len); } ``` @@ -266,4 +266,4 @@ for (int i = 0; i < param->rmt_srvcs.num_uuids; i++) { ## Conclusion -We have reviewed the Bluetooth discovery example code. This example searches for nearby devices. When the device of interest is found, the example searches for the services of this device. We can get the device discovery result and service discovery result from the GAP callback, which is registered in advance. \ No newline at end of file +We have reviewed the Bluetooth discovery example code. This example searches for nearby devices. When the device of interest is found, the example searches for the services of this device. We can get the device discovery result and service discovery result from the GAP callback, which is registered in advance. diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/main.c index df854cd22cc..b73c055edd5 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/main.c @@ -181,7 +181,7 @@ static void update_device_info(esp_bt_gap_cb_param_t *param) p_dev->eir_len = eir_len; } - if (p_dev->eir && p_dev->bdname_len == 0) { + if (p_dev->bdname_len == 0) { get_name_from_eir(p_dev->eir, p_dev->bdname, &p_dev->bdname_len); } diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c index faf28f61b70..372f1e80a71 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_hid_mouse_device/main/main.c @@ -262,7 +262,7 @@ void esp_bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param) ESP_LOGI(TAG, "setting hid parameters success!"); ESP_LOGI(TAG, "setting to connectable, discoverable"); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); - if (param->register_app.in_use && param->register_app.bd_addr != NULL) { + if (param->register_app.in_use) { ESP_LOGI(TAG, "start virtual cable plug!"); esp_bt_hid_device_connect(param->register_app.bd_addr); }