Fixed incorrect parameters in switching to BTC context

This commit is contained in:
xiongweichao 2022-10-19 16:17:08 +08:00
parent c0392d3dd9
commit 6fdd8552da
2 changed files with 4 additions and 2 deletions

View File

@ -239,6 +239,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
bt_status_t ret; bt_status_t ret;
// arg XOR arg_len // arg XOR arg_len
if ((msg == NULL) || ((arg == NULL) == !(arg_len == 0))) { if ((msg == NULL) || ((arg == NULL) == !(arg_len == 0))) {
BTC_TRACE_WARNING("%s Invalid parameters\n", __func__);
return BT_STATUS_PARM_INVALID; return BT_STATUS_PARM_INVALID;
} }
@ -246,6 +247,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
lmsg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + arg_len); lmsg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + arg_len);
if (lmsg == NULL) { if (lmsg == NULL) {
BTC_TRACE_WARNING("%s No memory\n", __func__);
return BT_STATUS_NOMEM; return BT_STATUS_NOMEM;
} }

View File

@ -51,7 +51,7 @@ esp_err_t esp_hf_ag_init(void)
msg.act = BTC_HF_INIT_EVT; msg.act = BTC_HF_INIT_EVT;
/* Switch to BTC context */ /* Switch to BTC context */
bt_status_t status = btc_transfer_context(&msg, NULL, sizeof(btc_hf_args_t), NULL, NULL); bt_status_t status = btc_transfer_context(&msg, NULL, 0, NULL, NULL);
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL; return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
} }
@ -66,7 +66,7 @@ esp_err_t esp_hf_ag_deinit(void)
msg.act = BTC_HF_DEINIT_EVT; msg.act = BTC_HF_DEINIT_EVT;
/* Switch to BTC context */ /* Switch to BTC context */
bt_status_t status = btc_transfer_context(&msg, NULL, sizeof(btc_hf_args_t), NULL, NULL); bt_status_t status = btc_transfer_context(&msg, NULL, 0, NULL, NULL);
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL; return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
} }