open.status = BTA_AV_SUCCESS;
open.starting = bta_av_chk_start(p_scb);
open.edr = 0;
- if (NULL != (p = BTM_ReadRemoteFeatures(p_scb->peer_addr))) {
+ p = BTM_ReadRemoteFeatures(p_scb->peer_addr);
+ if (p != NULL) {
if (HCI_EDR_ACL_2MPS_SUPPORTED(p)) open.edr |= BTA_AV_EDR_2MBPS;
if (HCI_EDR_ACL_3MPS_SUPPORTED(p)) open.edr |= BTA_AV_EDR_3MBPS;
}
/* store parameters */
bta_hd_cb.p_cback = p_data->api_enable.p_cback;
- if ((ret = HID_DevRegister(bta_hd_cback)) == HID_SUCCESS) {
+ ret = HID_DevRegister(bta_hd_cback);
+ if (ret == HID_SUCCESS) {
status = BTA_HD_OK;
} else {
APPL_TRACE_ERROR("%s: Failed to register HID device (%d)", __func__, ret);
}
/* Deregister with lower layer */
- if ((ret = HID_DevDeregister()) == HID_SUCCESS) {
+ ret = HID_DevDeregister();
+ if (ret == HID_SUCCESS) {
status = BTA_HD_OK;
} else {
APPL_TRACE_ERROR("%s: Failed to deregister HID device (%s)", __func__, ret);
*
******************************************************************************/
void BTA_HdEnable(tBTA_HD_CBACK* p_cback) {
- tBTA_HD_API_ENABLE* p_buf;
-
APPL_TRACE_API("%s", __func__);
bta_sys_register(BTA_ID_HD, &bta_hd_reg);
- p_buf = (tBTA_HD_API_ENABLE*)osi_malloc((uint16_t)sizeof(tBTA_HD_API_ENABLE));
+ tBTA_HD_API_ENABLE* p_buf =
+ (tBTA_HD_API_ENABLE*)osi_malloc((uint16_t)sizeof(tBTA_HD_API_ENABLE));
- if (p_buf != NULL) {
- memset(p_buf, 0, sizeof(tBTA_HD_API_ENABLE));
+ memset(p_buf, 0, sizeof(tBTA_HD_API_ENABLE));
- p_buf->hdr.event = BTA_HD_API_ENABLE_EVT;
- p_buf->p_cback = p_cback;
+ p_buf->hdr.event = BTA_HD_API_ENABLE_EVT;
+ p_buf->p_cback = p_cback;
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
void BTA_HdDisable(void) {
- BT_HDR* p_buf;
-
APPL_TRACE_API("%s", __func__);
bta_sys_deregister(BTA_ID_HD);
- if ((p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR))) != NULL) {
- p_buf->event = BTA_HD_API_DISABLE_EVT;
- bta_sys_sendmsg(p_buf);
- }
+ BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
+ p_buf->event = BTA_HD_API_DISABLE_EVT;
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO* p_app_info,
tBTA_HD_QOS_INFO* p_in_qos,
tBTA_HD_QOS_INFO* p_out_qos) {
- tBTA_HD_REGISTER_APP* p_buf;
-
APPL_TRACE_API("%s", __func__);
- if ((p_buf = (tBTA_HD_REGISTER_APP*)osi_malloc(
- sizeof(tBTA_HD_REGISTER_APP))) != NULL) {
- p_buf->hdr.event = BTA_HD_API_REGISTER_APP_EVT;
-
- if (p_app_info->p_name) {
- strncpy(p_buf->name, p_app_info->p_name, BTA_HD_APP_NAME_LEN);
- p_buf->name[BTA_HD_APP_NAME_LEN] = '\0';
- } else {
- p_buf->name[0] = '\0';
- }
-
- if (p_app_info->p_description) {
- strncpy(p_buf->description, p_app_info->p_description,
- BTA_HD_APP_DESCRIPTION_LEN);
- p_buf->description[BTA_HD_APP_DESCRIPTION_LEN] = '\0';
- } else {
- p_buf->description[0] = '\0';
- }
-
- if (p_app_info->p_provider) {
- strncpy(p_buf->provider, p_app_info->p_provider, BTA_HD_APP_PROVIDER_LEN);
- p_buf->provider[BTA_HD_APP_PROVIDER_LEN] = '\0';
- } else {
- p_buf->provider[0] = '\0';
- }
-
- p_buf->subclass = p_app_info->subclass;
-
- p_buf->d_len = p_app_info->descriptor.dl_len;
- memcpy(p_buf->d_data, p_app_info->descriptor.dsc_list,
- p_app_info->descriptor.dl_len);
-
- // copy qos data as-is
- memcpy(&p_buf->in_qos, p_in_qos, sizeof(tBTA_HD_QOS_INFO));
- memcpy(&p_buf->out_qos, p_out_qos, sizeof(tBTA_HD_QOS_INFO));
-
- bta_sys_sendmsg(p_buf);
+ tBTA_HD_REGISTER_APP* p_buf =
+ (tBTA_HD_REGISTER_APP*)osi_malloc(sizeof(tBTA_HD_REGISTER_APP));
+ p_buf->hdr.event = BTA_HD_API_REGISTER_APP_EVT;
+
+ if (p_app_info->p_name) {
+ strncpy(p_buf->name, p_app_info->p_name, BTA_HD_APP_NAME_LEN);
+ p_buf->name[BTA_HD_APP_NAME_LEN] = '\0';
+ } else {
+ p_buf->name[0] = '\0';
+ }
+
+ if (p_app_info->p_description) {
+ strncpy(p_buf->description, p_app_info->p_description,
+ BTA_HD_APP_DESCRIPTION_LEN);
+ p_buf->description[BTA_HD_APP_DESCRIPTION_LEN] = '\0';
+ } else {
+ p_buf->description[0] = '\0';
}
+
+ if (p_app_info->p_provider) {
+ strncpy(p_buf->provider, p_app_info->p_provider, BTA_HD_APP_PROVIDER_LEN);
+ p_buf->provider[BTA_HD_APP_PROVIDER_LEN] = '\0';
+ } else {
+ p_buf->provider[0] = '\0';
+ }
+
+ p_buf->subclass = p_app_info->subclass;
+
+ p_buf->d_len = p_app_info->descriptor.dl_len;
+ memcpy(p_buf->d_data, p_app_info->descriptor.dsc_list,
+ p_app_info->descriptor.dl_len);
+
+ // copy qos data as-is
+ memcpy(&p_buf->in_qos, p_in_qos, sizeof(tBTA_HD_QOS_INFO));
+ memcpy(&p_buf->out_qos, p_out_qos, sizeof(tBTA_HD_QOS_INFO));
+
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdUnregisterApp(void) {
- BT_HDR* p_buf;
-
APPL_TRACE_API("%s", __func__);
- if ((p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR))) != NULL) {
- p_buf->event = BTA_HD_API_UNREGISTER_APP_EVT;
+ BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
+ p_buf->event = BTA_HD_API_UNREGISTER_APP_EVT;
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdSendReport(tBTA_HD_REPORT* p_report) {
- tBTA_HD_SEND_REPORT* p_buf;
-
APPL_TRACE_VERBOSE("%s", __func__);
if (p_report->len > BTA_HD_REPORT_LEN) {
return;
}
- if ((p_buf = (tBTA_HD_SEND_REPORT*)osi_malloc(sizeof(tBTA_HD_SEND_REPORT))) !=
- NULL) {
- p_buf->hdr.event = BTA_HD_API_SEND_REPORT_EVT;
+ tBTA_HD_SEND_REPORT* p_buf =
+ (tBTA_HD_SEND_REPORT*)osi_malloc(sizeof(tBTA_HD_SEND_REPORT));
+ p_buf->hdr.event = BTA_HD_API_SEND_REPORT_EVT;
- p_buf->use_intr = p_report->use_intr;
- p_buf->type = p_report->type;
- p_buf->id = p_report->id;
- p_buf->len = p_report->len;
- memcpy(p_buf->data, p_report->p_data, p_report->len);
+ p_buf->use_intr = p_report->use_intr;
+ p_buf->type = p_report->type;
+ p_buf->id = p_report->id;
+ p_buf->len = p_report->len;
+ memcpy(p_buf->data, p_report->p_data, p_report->len);
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdVirtualCableUnplug(void) {
- BT_HDR* p_buf;
-
APPL_TRACE_API("%s", __func__);
- if ((p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR))) != NULL) {
- p_buf->event = BTA_HD_API_VC_UNPLUG_EVT;
+ BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
+ p_buf->event = BTA_HD_API_VC_UNPLUG_EVT;
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdConnect(BD_ADDR addr) {
- tBTA_HD_DEVICE_CTRL* p_buf;
-
APPL_TRACE_API("%s", __func__);
- if ((p_buf = (tBTA_HD_DEVICE_CTRL*)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL))) !=
- NULL) {
- p_buf->hdr.event = BTA_HD_API_CONNECT_EVT;
+ tBTA_HD_DEVICE_CTRL* p_buf =
+ (tBTA_HD_DEVICE_CTRL*)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL));
+ p_buf->hdr.event = BTA_HD_API_CONNECT_EVT;
- memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
+ memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdDisconnect(void) {
- BT_HDR* p_buf;
-
APPL_TRACE_API("%s", __func__);
+ BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
+ p_buf->event = BTA_HD_API_DISCONNECT_EVT;
- if ((p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR))) != NULL) {
- p_buf->event = BTA_HD_API_DISCONNECT_EVT;
-
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdAddDevice(BD_ADDR addr) {
- tBTA_HD_DEVICE_CTRL* p_buf;
-
APPL_TRACE_API("%s", __func__);
+ tBTA_HD_DEVICE_CTRL* p_buf =
+ (tBTA_HD_DEVICE_CTRL*)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL));
+ p_buf->hdr.event = BTA_HD_API_ADD_DEVICE_EVT;
- if ((p_buf = (tBTA_HD_DEVICE_CTRL*)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL))) !=
- NULL) {
- p_buf->hdr.event = BTA_HD_API_ADD_DEVICE_EVT;
+ memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
- memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
-
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdRemoveDevice(BD_ADDR addr) {
- tBTA_HD_DEVICE_CTRL* p_buf;
-
APPL_TRACE_API("%s", __func__);
+ tBTA_HD_DEVICE_CTRL* p_buf =
+ (tBTA_HD_DEVICE_CTRL*)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL));
+ p_buf->hdr.event = BTA_HD_API_REMOVE_DEVICE_EVT;
- if ((p_buf = (tBTA_HD_DEVICE_CTRL*)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL))) !=
- NULL) {
- p_buf->hdr.event = BTA_HD_API_REMOVE_DEVICE_EVT;
-
- memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
+ memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
/*******************************************************************************
*
******************************************************************************/
extern void BTA_HdReportError(uint8_t error) {
- tBTA_HD_REPORT_ERR* p_buf;
-
APPL_TRACE_API("%s", __func__);
+ tBTA_HD_REPORT_ERR* p_buf =
+ (tBTA_HD_REPORT_ERR*)osi_malloc(sizeof(tBTA_HD_REPORT_ERR));
+ p_buf->hdr.event = BTA_HD_API_REPORT_ERROR_EVT;
+ p_buf->error = error;
- if ((p_buf = (tBTA_HD_REPORT_ERR*)osi_malloc(sizeof(tBTA_HD_REPORT_ERR))) !=
- NULL) {
- p_buf->hdr.event = BTA_HD_API_REPORT_ERROR_EVT;
- p_buf->error = error;
-
- bta_sys_sendmsg(p_buf);
- }
+ bta_sys_sendmsg(p_buf);
}
#endif /* BTA_HD_INCLUDED */
event &= 0xff;
- if ((action = state_table[event][BTA_HD_ACTION]) < BTA_HD_IGNORE) {
+ action = state_table[event][BTA_HD_ACTION];
+ if (action < BTA_HD_IGNORE) {
(*bta_hd_action[action])(p_data);
}
*
******************************************************************************/
bool bta_hf_client_allocate_handle(const BD_ADDR bd_addr, uint16_t* p_handle) {
- tBTA_HF_CLIENT_CB* existing_cb;
- if ((existing_cb = bta_hf_client_find_cb_by_bda(bd_addr)) != NULL) {
+ tBTA_HF_CLIENT_CB* existing_cb = bta_hf_client_find_cb_by_bda(bd_addr);
+ if (existing_cb != NULL) {
BTIF_TRACE_ERROR("%s: cannot allocate handle since BDADDR already exists",
__func__);
return false;
if (bits > maxBits) {
maxBits = bits;
}
- if ((bitneeds[sb] = bits) > 1) {
+ bitneeds[sb] = bits;
+ if (bitneeds[sb] > 1) {
bitcount += bits;
}
prefBits += 2 + bits;
}
bits += 5;
}
- if ((bitneeds[sb] = bits) > 1) {
+ bitneeds[sb] = bits;
+ if (bitneeds[sb] > 1) {
bitcount += bits;
}
}
uint16_t AVCT_GetBrowseMtu(uint8_t handle) {
uint16_t peer_mtu = AVCT_MIN_BROWSE_MTU;
- tAVCT_CCB* p_ccb;
+ tAVCT_CCB* p_ccb = avct_ccb_by_idx(handle);
- if ((p_ccb = avct_ccb_by_idx(handle)) != NULL && p_ccb->p_bcb != NULL) {
+ if (p_ccb != NULL && p_ccb->p_bcb != NULL) {
peer_mtu = p_ccb->p_bcb->peer_mtu;
}
/* Map seid to the scb and send it the event. For cmd, seid has
** already been verified by parsing function.
*/
- if (evt && (p_scb = avdt_scb_by_hdl(scb_hdl)) != NULL) {
- avdt_scb_event(p_scb, evt, (tAVDT_SCB_EVT*)&msg);
+ if (evt) {
+ p_scb = avdt_scb_by_hdl(scb_hdl);
+ if (p_scb != NULL) {
+ avdt_scb_event(p_scb, evt, (tAVDT_SCB_EVT*)&msg);
+ }
}
}
}
BTM_TRACE_API("BTM_SecBondCancel() State: %s flags:0x%x",
btm_pair_state_descr(btm_cb.pairing_state),
btm_cb.pairing_flags);
-
- if (((p_dev_rec = btm_find_dev(bd_addr)) == NULL) ||
- (memcmp(btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0))
+ p_dev_rec = btm_find_dev(bd_addr);
+ if ((p_dev_rec == NULL) ||
+ (memcmp(btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN) != 0)) {
return BTM_UNKNOWN_ADDR;
+ }
if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_LE_ACTIVE) {
if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) {
******************************************************************************/
tBTM_STATUS BTM_SecGetDeviceLinkKey(BD_ADDR bd_addr, LINK_KEY link_key) {
tBTM_SEC_DEV_REC* p_dev_rec;
-
- if (((p_dev_rec = btm_find_dev(bd_addr)) != NULL) &&
- (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)) {
+ p_dev_rec = btm_find_dev(bd_addr);
+ if ((p_dev_rec != NULL) && (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)) {
memcpy(link_key, p_dev_rec->link_key, LINK_KEY_LEN);
return (BTM_SUCCESS);
}
(p_bda[4] << 8) + p_bda[5], event,
btm_pair_state_descr(btm_cb.pairing_state));
- if (((p_dev_rec = btm_find_dev(p_bda)) != NULL) &&
- (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) &&
+ p_dev_rec = btm_find_dev(p_bda);
+ if ((p_dev_rec != NULL) && (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) &&
(memcmp(btm_cb.pairing_bda, p_bda, BD_ADDR_LEN) == 0)) {
memcpy(evt_data.cfm_req.bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
memcpy(evt_data.cfm_req.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN);
On Mobile platforms, if there's a security process happening,
the host probably can not initiate another connection.
BTW (PC) is another story. */
- if (NULL != (p_dev_rec = btm_find_dev(p_bda))) {
+ p_dev_rec = btm_find_dev(p_bda);
+ if (p_dev_rec != NULL) {
btm_sec_disconnect(p_dev_rec->hci_handle, HCI_ERR_AUTH_FAILURE);
}
}
BTM_TRACE_EVENT("btm_rem_oob_req() BDA: %02x:%02x:%02x:%02x:%02x:%02x",
p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]);
-
- if ((NULL != (p_dev_rec = btm_find_dev(p_bda))) && btm_cb.api.p_sp_callback) {
+ p_dev_rec = btm_find_dev(p_bda);
+ if ((p_dev_rec != NULL) && btm_cb.api.p_sp_callback) {
memcpy(evt_data.bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
memcpy(evt_data.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN);
strlcpy((char*)evt_data.bd_name, (char*)p_dev_rec->sec_bd_name,
GATT_TRACE_API("GATT_CancelConnect gatt_if=%d", gatt_if);
- if ((gatt_if != 0) && ((p_reg = gatt_get_regcb(gatt_if)) == NULL)) {
- GATT_TRACE_ERROR("GATT_CancelConnect - gatt_if =%d is not registered",
- gatt_if);
- return (false);
+ if (gatt_if != 0) {
+ p_reg = gatt_get_regcb(gatt_if);
+ if (p_reg == NULL) {
+ GATT_TRACE_ERROR("GATT_CancelConnect - gatt_if =%d is not registered",
+ gatt_if);
+ return (false);
+ }
}
if (is_direct) {
if (host_cback == NULL) return HID_ERR_INVALID_PARAM;
/* Register with L2CAP */
- if ((st = hidd_conn_reg()) != HID_SUCCESS) {
- return st;
- }
+ st = hidd_conn_reg();
+ if (st != HID_SUCCESS) return st;
hd_cb.callback = host_cback;
hd_cb.reg_flag = TRUE;
p_lcb = &l2cb.lcb_pool[0];
for (ii = 0; ii < MAX_L2CAP_LINKS; ii++, p_lcb++) {
if (p_lcb->in_use) {
- if (((p_ccb = p_lcb->ccb_queue.p_first_ccb) == NULL) ||
- (p_lcb->link_state == LST_DISCONNECTING))
+ p_ccb = p_lcb->ccb_queue.p_first_ccb;
+ if ((p_ccb == NULL) || (p_lcb->link_state == LST_DISCONNECTING)) {
continue;
+ }
if ((p_ccb->in_use) &&
((p_ccb->chnl_state == CST_W4_L2CAP_DISCONNECT_RSP) ||
- (p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP)))
+ (p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP))) {
continue;
+ }
- if (p_ccb->p_rcb == p_rcb)
+ if (p_ccb->p_rcb == p_rcb) {
l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_REQ, NULL);
+ }
}
}
l2cu_release_rcb(p_rcb);
p_lcb = l2cu_find_lcb_by_bd_addr(p_bd_addr, BT_TRANSPORT_BR_EDR);
if (p_lcb == NULL) {
/* No link. Get an LCB and start link establishment */
- if (((p_lcb = l2cu_allocate_lcb(p_bd_addr, false, BT_TRANSPORT_BR_EDR)) ==
- NULL)
- /* currently use BR/EDR for ERTM mode l2cap connection */
- || (l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR) == false)) {
+ p_lcb = l2cu_allocate_lcb(p_bd_addr, false, BT_TRANSPORT_BR_EDR);
+ /* currently use BR/EDR for ERTM mode l2cap connection */
+ if ((p_lcb == NULL) ||
+ (l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR) == false)) {
L2CAP_TRACE_WARNING(
"L2CAP - conn not started for PSM: 0x%04x p_lcb: 0x%08x", psm,
p_lcb);
}
// We need to have a link up
- if ((p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport)) == NULL ||
- /* if link is disconnecting, also report data sending failure */
- p_lcb->link_state == LST_DISCONNECTING) {
+ p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
+ if (p_lcb == NULL || p_lcb->link_state == LST_DISCONNECTING) {
+ /* if link is disconnecting, also report data sending failure */
L2CAP_TRACE_WARNING("L2CA_SendFixedChnlData(0x%04x) - no LCB", fixed_cid);
osi_free(p_buf);
return (L2CAP_DW_FAILED);
p_ccb = l2cu_find_ccb_by_cid(NULL, lcid);
- if (!p_ccb || ((p_lcb = p_ccb->p_lcb) == NULL)) {
+ if (!p_ccb || (p_ccb->p_lcb == NULL)) {
L2CAP_TRACE_WARNING(
"L2CA_FlushChannel() abnormally returning 0 CID: 0x%04x", lcid);
return (0);
}
+ p_lcb = p_ccb->p_lcb;
if (num_to_flush != L2CAP_FLUSH_CHANS_GET) {
L2CAP_TRACE_API(
/* An L2CAP packet may contain multiple commands */
while (true) {
/* Smallest command is 4 bytes */
- if ((p = p_next_cmd) > (p_pkt_end - 4)) break;
+ p = p_next_cmd;
+ if (p > (p_pkt_end - 4)) break;
STREAM_TO_UINT8(cmd_code, p);
STREAM_TO_UINT8(id, p);
}
/* Check command length does not exceed packet length */
- if ((p_next_cmd = p + cmd_len) > p_pkt_end) {
+ p_next_cmd = p + cmd_len;
+ if (p_next_cmd > p_pkt_end) {
L2CAP_TRACE_WARNING("Command len bad pkt_len: %d cmd_len: %d code: %d",
pkt_len, cmd_len, cmd_code);
break;
rcid);
/* Remote CID invalid. Treat as a disconnect */
- if (((p_ccb = l2cu_find_ccb_by_cid(p_lcb, lcid)) != NULL) &&
- (p_ccb->remote_cid == rcid)) {
+ p_ccb = l2cu_find_ccb_by_cid(p_lcb, lcid);
+ if ((p_ccb != NULL) && (p_ccb->remote_cid == rcid)) {
/* Fake link disconnect - no reply is generated */
l2c_csm_execute(p_ccb, L2CEVT_LP_DISCONNECT_IND, NULL);
}
/* For the server side always allocate a new port. On the client side */
/* do not allow the same (dlci, bd_addr) to be opened twice by application */
- if (!is_server && ((p_port = port_find_port(dlci, bd_addr)) != NULL)) {
- /* if existing port is also a client port */
- if (p_port->is_server == false) {
- RFCOMM_TRACE_ERROR(
- "RFCOMM_CreateConnection - already opened state:%d, RFC state:%d, "
- "MCB state:%d",
- p_port->state, p_port->rfc.state,
- p_port->rfc.p_mcb ? p_port->rfc.p_mcb->state : 0);
- *p_handle = p_port->inx;
- return (PORT_ALREADY_OPENED);
+ if (!is_server) {
+ p_port = port_find_port(dlci, bd_addr);
+ if (p_port != NULL) {
+ /* if existing port is also a client port */
+ if (p_port->is_server == false) {
+ RFCOMM_TRACE_ERROR(
+ "RFCOMM_CreateConnection - already opened state:%d, RFC state:%d, "
+ "MCB state:%d",
+ p_port->state, p_port->rfc.state,
+ p_port->rfc.p_mcb ? p_port->rfc.p_mcb->state : 0);
+ *p_handle = p_port->inx;
+ return (PORT_ALREADY_OPENED);
+ }
}
}
/* data fits into the end of the queue */
mutex_global_lock();
- if (((p_buf = (BT_HDR*)fixed_queue_try_peek_last(p_port->tx.queue)) !=
- NULL) &&
+ p_buf = (BT_HDR*)fixed_queue_try_peek_last(p_port->tx.queue);
+ if ((p_buf != NULL) &&
(((int)p_buf->len + available) <= (int)p_port->peer_mtu) &&
(((int)p_buf->len + available) <= (int)length)) {
// if(recv(fd, (uint8_t *)(p_buf + 1) + p_buf->offset + p_buf->len,
/* data fits into the end of the queue */
mutex_global_lock();
- if (((p_buf = (BT_HDR*)fixed_queue_try_peek_last(p_port->tx.queue)) !=
- NULL) &&
- ((p_buf->len + max_len) <= p_port->peer_mtu) &&
+ p_buf = (BT_HDR*)fixed_queue_try_peek_last(p_port->tx.queue);
+ if ((p_buf != NULL) && ((p_buf->len + max_len) <= p_port->peer_mtu) &&
((p_buf->len + max_len) <= length)) {
memcpy((uint8_t*)(p_buf + 1) + p_buf->offset + p_buf->len, p_data, max_len);
p_port->tx.queue_size += max_len;
int channel;
sock_connect_signal_t signal;
- if ((len = read(fd, &channel, sizeof(channel))) != sizeof(channel)) {
+ len = read(fd, &channel, sizeof(channel));
+ if (len != sizeof(channel)) {
ADD_FAILURE() << "Channel not read from RFCOMM socket. Bytes read: "
<< len << ", Sizeof channel: " << sizeof(channel);
channel_fail++;
}
- if ((len = read(fd, &signal, sizeof(signal))) != sizeof(signal)) {
+ len = read(fd, &signal, sizeof(signal));
+ if (len != sizeof(signal)) {
ADD_FAILURE()
<< "Connection signal not read from RFCOMM socket. Bytes read: "
<< len;
EXPECT_TRUE(channel == signal.channel)
<< "Inconsistent channels returned: " << channel << " and "
<< signal.channel;
-
- if ((len = write(fd, HANDSHAKE_COMMAND, sizeof(HANDSHAKE_COMMAND))) !=
- sizeof(HANDSHAKE_COMMAND)) {
+ len = write(fd, HANDSHAKE_COMMAND, sizeof(HANDSHAKE_COMMAND));
+ if (len != sizeof(HANDSHAKE_COMMAND)) {
ADD_FAILURE() << "Unable to send HFP handshake. Bytes written: " << len;
handshake_fail++;
}
char response[1024];
- if ((len = read(fd, response, sizeof(response))) <= 0) {
+ len = read(fd, response, sizeof(response));
+ if (len <= 0) {
ADD_FAILURE() << "Read " << len << " bytes";
read_fail++;
}