summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author William Escande <wescande@google.com> 2024-11-07 10:34:16 -0800
committer William Escande <wescande@google.com> 2024-11-08 09:46:32 -0800
commit4607506725f378a21c91adc443c5b9f3ac22cbbd (patch)
tree672b10e5b7cdc553c80a29afe46c16e0c2992665
parentdf850d2a664e71d27f88d545e41f5432cb96bf39 (diff)
cpplint: fix and enable whitespace/newline
Done with a combination of: sed -i 'N;s|\(^ *// .*\)\n\( *else.*\)|\2\n\1|;P;D' $i sed -i 'N;s|\(^ */\* .*\)\n\( *else.*\)|\2\n\1|;P;D' $i sed -i 'N;s|\(^ */\*\* .*\)\n\( *else.*\)|\2\n\1|;P;D' $i sed -i 'N;s|\(^ *\* .*\)\n\( *else.*\)|\2\n\1|;P;D' $i + repo upload formatter Bug: 364967694 Test: m . Flag: Exempt refactor Change-Id: Ie1af09932f2508da5ed94c625b8c4052ab2c1e78
-rw-r--r--CPPLINT.cfg2
-rw-r--r--system/bta/ag/bta_ag_at.cc10
-rw-r--r--system/bta/ag/bta_ag_cmd.cc7
-rw-r--r--system/bta/ag/bta_ag_sco.cc5
-rw-r--r--system/bta/ag/bta_ag_sdp.cc10
-rw-r--r--system/bta/av/bta_av_act.cc17
-rw-r--r--system/bta/av/bta_av_int.h6
-rw-r--r--system/bta/dm/bta_dm_device_search.cc6
-rw-r--r--system/bta/dm/bta_dm_pm.cc10
-rw-r--r--system/bta/gatt/bta_gattc_act.cc19
-rw-r--r--system/bta/hf_client/bta_hf_client_act.cc5
-rw-r--r--system/bta/hf_client/bta_hf_client_rfc.cc5
-rw-r--r--system/bta/hf_client/bta_hf_client_sco.cc5
-rw-r--r--system/bta/hf_client/bta_hf_client_sdp.cc5
-rw-r--r--system/bta/hh/bta_hh_le.cc22
-rw-r--r--system/bta/pan/bta_pan_act.cc10
-rw-r--r--system/bta/sys/utl.cc5
-rw-r--r--system/stack/acl/btm_acl.cc18
-rw-r--r--system/stack/avct/avct_api.cc15
-rw-r--r--system/stack/avct/avct_lcb_act.cc39
-rw-r--r--system/stack/avdt/avdt_api.cc59
-rw-r--r--system/stack/avdt/avdt_ccb_act.cc5
-rw-r--r--system/stack/avdt/avdt_msg.cc49
-rw-r--r--system/stack/avdt/avdt_scb_act.cc5
-rw-r--r--system/stack/avrc/avrc_api.cc5
-rw-r--r--system/stack/btm/btm_ble_adv_filter.cc6
-rw-r--r--system/stack/btm/btm_ble_gap.cc8
-rw-r--r--system/stack/btm/btm_ble_sec.cc5
-rw-r--r--system/stack/btm/btm_sec.cc67
-rw-r--r--system/stack/btm/btm_sec_cb.cc5
-rw-r--r--system/stack/gatt/gatt_cl.cc12
-rw-r--r--system/stack/gatt/gatt_db.cc33
-rw-r--r--system/stack/gatt/gatt_main.cc6
-rw-r--r--system/stack/hid/hidh_api.cc4
-rw-r--r--system/stack/l2cap/l2c_api.cc15
-rw-r--r--system/stack/l2cap/l2c_fcr.cc11
-rw-r--r--system/stack/l2cap/l2c_link.cc22
-rw-r--r--system/stack/rfcomm/port_rfc.cc5
-rw-r--r--system/stack/rfcomm/port_utils.cc31
-rw-r--r--system/stack/smp/smp_act.cc9
40 files changed, 234 insertions, 349 deletions
diff --git a/CPPLINT.cfg b/CPPLINT.cfg
index 23248637ae..61d9c70304 100644
--- a/CPPLINT.cfg
+++ b/CPPLINT.cfg
@@ -5,8 +5,6 @@ linelength=100
filter=-whitespace/indent
# TODO: b/364967694 re-enable the warning
-filter=-whitespace/newline
-# TODO: b/364967694 re-enable the warning
filter=-whitespace/blank_line
# TODO: b/364967694 re-enable the warning
filter=-readability/check
diff --git a/system/bta/ag/bta_ag_at.cc b/system/bta/ag/bta_ag_at.cc
index a42017c29b..8b1e3c6792 100644
--- a/system/bta/ag/bta_ag_at.cc
+++ b/system/bta/ag/bta_ag_at.cc
@@ -110,14 +110,12 @@ static void bta_ag_process_at(tBTA_AG_AT_CB* p_cb, char* p_end) {
/* if no argument */
if (p_arg[0] == 0) {
arg_type = BTA_AG_AT_NONE;
- }
- /* else if arg is '?' and it is last character */
- else if (p_arg[0] == '?' && p_arg[1] == 0) {
+ } else if (p_arg[0] == '?' && p_arg[1] == 0) {
+ /* else if arg is '?' and it is last character */
/* we have a read */
arg_type = BTA_AG_AT_READ;
- }
- /* else if arg is '=' */
- else if (p_arg[0] == '=' && p_arg[1] != 0) {
+ } else if (p_arg[0] == '=' && p_arg[1] != 0) {
+ /* else if arg is '=' */
if (p_arg[1] == '?' && p_arg[2] == 0) {
/* we have a test */
arg_type = BTA_AG_AT_TEST;
diff --git a/system/bta/ag/bta_ag_cmd.cc b/system/bta/ag/bta_ag_cmd.cc
index 75e9bfb22a..458608021e 100644
--- a/system/bta/ag/bta_ag_cmd.cc
+++ b/system/bta/ag/bta_ag_cmd.cc
@@ -942,10 +942,9 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, cha
event = BTA_AG_ENABLE_EVT;
bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
}
- }
- /* If dial cmd, make sure string contains only dial digits
- ** Dial digits are 0-9, A-C, *, #, + */
- else {
+ } else {
+ /* If dial cmd, make sure string contains only dial digits
+ ** Dial digits are 0-9, A-C, *, #, + */
/* Some car kits may add some unwanted space characters in the
** input string. This workaround will trim the unwanted chars. */
remove_spaces(val.str);
diff --git a/system/bta/ag/bta_ag_sco.cc b/system/bta/ag/bta_ag_sco.cc
index c9b30693cd..dd14e86779 100644
--- a/system/bta/ag/bta_ag_sco.cc
+++ b/system/bta/ag/bta_ag_sco.cc
@@ -174,9 +174,8 @@ static void bta_ag_sco_conn_cback(uint16_t sco_idx) {
/* match callback to scb; first check current sco scb */
if (bta_ag_cb.sco.p_curr_scb != nullptr && bta_ag_cb.sco.p_curr_scb->in_use) {
handle = bta_ag_scb_to_idx(bta_ag_cb.sco.p_curr_scb);
- }
- /* then check for scb connected to this peer */
- else {
+ } else {
+ /* then check for scb connected to this peer */
/* Check if SLC is up */
handle = bta_ag_idx_by_bdaddr(BTM_ReadScoBdAddr(sco_idx));
p_scb = bta_ag_scb_by_idx(handle);
diff --git a/system/bta/ag/bta_ag_sdp.cc b/system/bta/ag/bta_ag_sdp.cc
index 038b3fffdf..3d0420b77b 100644
--- a/system/bta/ag/bta_ag_sdp.cc
+++ b/system/bta/ag/bta_ag_sdp.cc
@@ -466,17 +466,15 @@ void bta_ag_do_disc(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
attr_list[3] = ATTR_ID_SUPPORTED_FEATURES;
num_attr = 4;
uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HF_HANDSFREE);
- }
- /* HFP acceptor; get features */
- else if (service & BTA_HFP_SERVICE_MASK && p_scb->role == BTA_AG_ACP) {
+ } else if (service & BTA_HFP_SERVICE_MASK && p_scb->role == BTA_AG_ACP) {
+ /* HFP acceptor; get features */
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
attr_list[1] = ATTR_ID_BT_PROFILE_DESC_LIST;
attr_list[2] = ATTR_ID_SUPPORTED_FEATURES;
num_attr = 3;
uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HF_HANDSFREE);
- }
- /* HSP initiator; get proto list */
- else if (service & BTA_HSP_SERVICE_MASK && p_scb->role == BTA_AG_INT) {
+ } else if (service & BTA_HSP_SERVICE_MASK && p_scb->role == BTA_AG_INT) {
+ /* HSP initiator; get proto list */
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
diff --git a/system/bta/av/bta_av_act.cc b/system/bta/av/bta_av_act.cc
index a01920504d..5a59222a33 100644
--- a/system/bta/av/bta_av_act.cc
+++ b/system/bta/av/bta_av_act.cc
@@ -1015,10 +1015,9 @@ void bta_av_rc_msg(tBTA_AV_CB* p_cb, tBTA_AV_DATA* p_data) {
memcpy(&av.remote_cmd.hdr, &p_data->rc_msg.msg.hdr, sizeof(tAVRC_HDR));
av.remote_cmd.label = p_data->rc_msg.label;
}
- }
- /* else if this is a pass thru response */
- /* id response type is not impl, we have to release label */
- else if (p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_NOT_IMPL) {
+ } else if (p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_NOT_IMPL) {
+ /* else if this is a pass thru response */
+ /* id response type is not impl, we have to release label */
/* set up for callback */
evt = BTA_AV_REMOTE_RSP_EVT;
av.remote_rsp.rc_id = p_data->rc_msg.msg.pass.op_id;
@@ -1036,15 +1035,13 @@ void bta_av_rc_msg(tBTA_AV_CB* p_cb, tBTA_AV_DATA* p_data) {
memcpy(av.remote_rsp.p_data, p_data->rc_msg.msg.pass.p_pass_data,
p_data->rc_msg.msg.pass.pass_len);
}
- }
- /* must be a bad ctype -> reject*/
- else {
+ } else {
+ /* must be a bad ctype -> reject*/
p_data->rc_msg.msg.hdr.ctype = AVRC_RSP_REJ;
AVRC_PassRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.pass);
}
- }
- /* else if this is a vendor specific command or response */
- else if (p_data->rc_msg.opcode == AVRC_OP_VENDOR) {
+ } else if (p_data->rc_msg.opcode == AVRC_OP_VENDOR) {
+ /* else if this is a vendor specific command or response */
/* set up for callback */
av.vendor_cmd.code = p_data->rc_msg.msg.hdr.ctype;
av.vendor_cmd.company_id = p_vendor->company_id;
diff --git a/system/bta/av/bta_av_int.h b/system/bta/av/bta_av_int.h
index 4f9773344e..a7ed265798 100644
--- a/system/bta/av/bta_av_int.h
+++ b/system/bta/av/bta_av_int.h
@@ -531,9 +531,9 @@ public:
* is set according to RFC 6416 */
uint8_t co_started; /* non-zero, if stream started from call-out perspective */
bool recfg_sup; /* true if the first attempt to reconfigure the stream was
- successful, else False if command fails */
- bool suspend_sup; /* true if Suspend stream is supported, else false if
- suspend command fails */
+ successful, false if command fails */
+ bool suspend_sup; /* true if Suspend stream is supported, false if suspend command
+ fails */
bool deregistering; /* true if deregistering */
bool sco_suspend; /* true if SUSPEND is issued automatically for SCO */
uint8_t coll_mask; /* Mask to check incoming and outgoing collision */
diff --git a/system/bta/dm/bta_dm_device_search.cc b/system/bta/dm/bta_dm_device_search.cc
index 76219c3fbb..c80f76396a 100644
--- a/system/bta/dm/bta_dm_device_search.cc
+++ b/system/bta/dm/bta_dm_device_search.cc
@@ -137,10 +137,8 @@ static void bta_dm_search_cancel() {
BTM_CancelInquiry();
bta_dm_search_cancel_notify();
bta_dm_search_cmpl();
- }
- /* If no Service Search going on then issue cancel remote name in case it is
- active */
- else if (!bta_dm_search_cb.name_discover_done) {
+ } else if (!bta_dm_search_cb.name_discover_done) {
+ /* If no Service Search going on then issue cancel remote name in case it is active */
if (get_stack_rnr_interface().BTM_CancelRemoteDeviceName() != tBTM_STATUS::BTM_CMD_STARTED) {
log::warn("Unable to cancel RNR");
}
diff --git a/system/bta/dm/bta_dm_pm.cc b/system/bta/dm/bta_dm_pm.cc
index ca3bb38058..9c0b869d30 100644
--- a/system/bta/dm/bta_dm_pm.cc
+++ b/system/bta/dm/bta_dm_pm.cc
@@ -393,9 +393,8 @@ static void bta_dm_sniff_cback(uint8_t id, uint8_t app_id, const RawAddress& pee
/* first check if the first preference is ok */
if (!(failed_pm & p_act0->power_mode)) {
timeout_ms = p_act0->timeout;
- }
- /* if first preference has already failed, try second preference */
- else if (!(failed_pm & p_act1->power_mode)) {
+ } else if (!(failed_pm & p_act1->power_mode)) {
+ /* if first preference has already failed, try second preference */
timeout_ms = p_act1->timeout;
}
@@ -649,9 +648,8 @@ static void bta_dm_pm_set_mode(const RawAddress& peer_addr, tBTA_DM_PM_ACTION pm
timeout_ms = p_act0->timeout;
}
}
- }
- /* if first preference has already failed, try second preference */
- else if (!(failed_pm & p_act1->power_mode)) {
+ } else if (!(failed_pm & p_act1->power_mode)) {
+ /* if first preference has already failed, try second preference */
pref_modes |= p_act1->power_mode;
if (p_act1->power_mode > pm_action) {
diff --git a/system/bta/gatt/bta_gattc_act.cc b/system/bta/gatt/bta_gattc_act.cc
index 1374cca1c5..c1a8e956ad 100644
--- a/system/bta/gatt/bta_gattc_act.cc
+++ b/system/bta/gatt/bta_gattc_act.cc
@@ -634,9 +634,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
} else { /* cache is building */
p_clcb->state = BTA_GATTC_DISCOVER_ST;
}
- }
-
- else {
+ } else {
/* a pending service handle change indication */
if (p_clcb->p_srcb->srvc_hdl_chg) {
p_clcb->p_srcb->srvc_hdl_chg = false;
@@ -932,9 +930,8 @@ void bta_gattc_start_discover(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* /*
}
bta_gattc_continue_with_version_and_cache_known(p_clcb, cache_support, is_svc_chg);
- }
- /* pending operation, wait until it finishes */
- else {
+ } else {
+ /* pending operation, wait until it finishes */
p_clcb->auto_update = BTA_GATTC_DISC_WAITING;
if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) {
@@ -1021,9 +1018,8 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* /* p_da
/* start discovery again */
p_clcb->auto_update = BTA_GATTC_REQ_WAITING;
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
- }
- /* get any queued command to proceed */
- else if (p_q_cmd != NULL) {
+ } else if (p_q_cmd != NULL) {
+ /* get any queued command to proceed */
p_clcb->p_q_cmd = NULL;
/* execute pending operation of link block still present */
if (bluetooth::stack::l2cap::get_interface().L2CA_IsLinkEstablished(p_clcb->p_srcb->server_bda,
@@ -1713,9 +1709,8 @@ static void bta_gattc_process_indicate(tCONN_ID conn_id, tGATTC_OPTYPE op,
if (p_clcb != NULL) {
bta_gattc_proc_other_indication(p_clcb, op, p_data, &notify);
}
- }
- /* no one intersted and need ack? */
- else if (op == GATTC_OPTYPE_INDICATION) {
+ } else if (op == GATTC_OPTYPE_INDICATION) {
+ /* no one interested and need ack? */
log::verbose("no one interested, ack now");
if (GATTC_SendHandleValueConfirm(conn_id, p_data->cid) != GATT_SUCCESS) {
log::warn("Unable to send GATT client handle value confirmation conn_id:{} cid:{}", conn_id,
diff --git a/system/bta/hf_client/bta_hf_client_act.cc b/system/bta/hf_client/bta_hf_client_act.cc
index c660f7a413..31daf28b4e 100644
--- a/system/bta/hf_client/bta_hf_client_act.cc
+++ b/system/bta/hf_client/bta_hf_client_act.cc
@@ -300,9 +300,8 @@ void bta_hf_client_rfc_close(tBTA_HF_CLIENT_DATA* p_data) {
bta_hf_client_sco_shutdown(client_cb);
bta_sys_sco_unuse(BTA_ID_HS, 1, client_cb->peer_addr);
- }
- /* else close port and deallocate scb */
- else {
+ } else {
+ /* else close port and deallocate scb */
tBTA_HF_CLIENT evt;
memset(&evt, 0, sizeof(evt));
evt.reg.bd_addr = client_cb->peer_addr;
diff --git a/system/bta/hf_client/bta_hf_client_rfc.cc b/system/bta/hf_client/bta_hf_client_rfc.cc
index 262d31d267..48c6d49c80 100644
--- a/system/bta/hf_client/bta_hf_client_rfc.cc
+++ b/system/bta/hf_client/bta_hf_client_rfc.cc
@@ -244,9 +244,8 @@ void bta_hf_client_rfc_do_open(tBTA_HF_CLIENT_DATA* p_data) {
BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT) == PORT_SUCCESS) {
bta_hf_client_setup_port(client_cb->conn_handle);
log::verbose("bta_hf_client_rfc_do_open : conn_handle = {}", client_cb->conn_handle);
- }
- /* RFCOMM create connection failed; send ourselves RFCOMM close event */
- else {
+ } else {
+ /* RFCOMM create connection failed; send ourselves RFCOMM close event */
bta_hf_client_sm_execute(BTA_HF_CLIENT_RFC_CLOSE_EVT, p_data);
}
}
diff --git a/system/bta/hf_client/bta_hf_client_sco.cc b/system/bta/hf_client/bta_hf_client_sco.cc
index f22077a48c..aa3f47f453 100644
--- a/system/bta/hf_client/bta_hf_client_sco.cc
+++ b/system/bta/hf_client/bta_hf_client_sco.cc
@@ -64,9 +64,8 @@ static bool bta_hf_client_sco_remove(tBTA_HF_CLIENT_CB* client_cb) {
if (status == tBTM_STATUS::BTM_CMD_STARTED) {
removed_started = true;
- }
- /* If no connection reset the SCO handle */
- else if ((status == tBTM_STATUS::BTM_SUCCESS) || (status == tBTM_STATUS::BTM_UNKNOWN_ADDR)) {
+ } else if ((status == tBTM_STATUS::BTM_SUCCESS) || (status == tBTM_STATUS::BTM_UNKNOWN_ADDR)) {
+ /* If no connection reset the SCO handle */
client_cb->sco_idx = BTM_INVALID_SCO_INDEX;
}
}
diff --git a/system/bta/hf_client/bta_hf_client_sdp.cc b/system/bta/hf_client/bta_hf_client_sdp.cc
index 94ebd87917..d967b40ff6 100644
--- a/system/bta/hf_client/bta_hf_client_sdp.cc
+++ b/system/bta/hf_client/bta_hf_client_sdp.cc
@@ -335,9 +335,8 @@ void bta_hf_client_do_disc(tBTA_HF_CLIENT_CB* client_cb) {
attr_list[3] = ATTR_ID_SUPPORTED_FEATURES;
num_attr = 4;
uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_AG_HANDSFREE);
- }
- /* acceptor; get features */
- else {
+ } else {
+ /* acceptor; get features */
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
attr_list[1] = ATTR_ID_BT_PROFILE_DESC_LIST;
attr_list[2] = ATTR_ID_SUPPORTED_FEATURES;
diff --git a/system/bta/hh/bta_hh_le.cc b/system/bta/hh/bta_hh_le.cc
index c1f4447dc9..37f1a63cb7 100644
--- a/system/bta/hh/bta_hh_le.cc
+++ b/system/bta/hh/bta_hh_le.cc
@@ -542,18 +542,16 @@ static void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB* p_dev_cb, uint8_t pro
if (register_ba && p_rpt->uuid == GATT_UUID_BATTERY_LEVEL) {
BTA_GATTC_RegisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->link_spec.addrt.bda,
p_rpt->char_inst_id);
- }
- /* boot mode, deregister report input notification */
- else if (proto_mode == BTA_HH_PROTO_BOOT_MODE) {
+ } else if (proto_mode == BTA_HH_PROTO_BOOT_MODE) {
+ /* boot mode, deregister report input notification */
if (p_rpt->uuid == GATT_UUID_HID_REPORT &&
p_rpt->client_cfg_value == GATT_CLT_CONFIG_NOTIFICATION) {
log::verbose("---> Deregister Report ID:{}", p_rpt->rpt_id);
BTA_GATTC_DeregisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->link_spec.addrt.bda,
p_rpt->char_inst_id);
- }
- /* register boot reports notification */
- else if (p_rpt->uuid == GATT_UUID_HID_BT_KB_INPUT ||
- p_rpt->uuid == GATT_UUID_HID_BT_MOUSE_INPUT) {
+ } else if (p_rpt->uuid == GATT_UUID_HID_BT_KB_INPUT ||
+ /* register boot reports notification */
+ p_rpt->uuid == GATT_UUID_HID_BT_MOUSE_INPUT) {
log::verbose("<--- Register Boot Report ID:{}", p_rpt->rpt_id);
BTA_GATTC_RegisterForNotifications(bta_hh_cb.gatt_if, p_dev_cb->link_spec.addrt.bda,
p_rpt->char_inst_id);
@@ -1026,9 +1024,8 @@ void bta_hh_security_cmpl(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* /* p_buf */)
if (!bta_hh_le_set_protocol_mode(p_cb, p_cb->mode)) {
bta_hh_le_open_cmpl(p_cb);
}
- }
- /* start primary service discovery for HID service */
- else {
+ } else {
+ /* start primary service discovery for HID service */
log::verbose("Starting service discovery");
bta_hh_le_pri_service_discovery(p_cb);
}
@@ -1103,9 +1100,8 @@ void bta_hh_start_security(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* /* p_buf */
log::debug("addr:{} already encrypted", p_cb->link_spec.addrt.bda);
p_cb->status = BTA_HH_OK;
bta_hh_sm_execute(p_cb, BTA_HH_ENC_CMPL_EVT, NULL);
- }
- /* if bonded and link not encrypted */
- else if (BTM_IsLinkKeyKnown(p_cb->link_spec.addrt.bda, BT_TRANSPORT_LE)) {
+ } else if (BTM_IsLinkKeyKnown(p_cb->link_spec.addrt.bda, BT_TRANSPORT_LE)) {
+ /* if bonded and link not encrypted */
log::debug("addr:{} bonded, not encrypted", p_cb->link_spec.addrt.bda);
p_cb->status = BTA_HH_ERR_AUTH_FAILED;
BTM_SetEncryption(p_cb->link_spec.addrt.bda, BT_TRANSPORT_LE, bta_hh_le_encrypt_cback, NULL,
diff --git a/system/bta/pan/bta_pan_act.cc b/system/bta/pan/bta_pan_act.cc
index fa24534bd9..2ecc793111 100644
--- a/system/bta/pan/bta_pan_act.cc
+++ b/system/bta/pan/bta_pan_act.cc
@@ -348,9 +348,8 @@ void bta_pan_set_role(tBTA_PAN_DATA* p_data) {
} else {
bta_sys_remove_uuid(UUID_SERVCLASS_PANU);
}
- }
- /* if status is not success clear everything */
- else {
+ } else {
+ /* if status is not success clear everything */
PAN_SetRole(0, std::string(), std::string());
bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
bta_sys_remove_uuid(UUID_SERVCLASS_GN);
@@ -547,9 +546,8 @@ void bta_pan_rx_path(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* /* p_data */) {
/* call application callout function for rx path */
bta_pan_co_rx_path(p_scb->handle, p_scb->app_id);
}
- }
- /* else data path configured for rx push */
- else {
+ } else {
+ /* else data path configured for rx push */
}
}
diff --git a/system/bta/sys/utl.cc b/system/bta/sys/utl.cc
index aa421d76bb..2d625083c5 100644
--- a/system/bta/sys/utl.cc
+++ b/system/bta/sys/utl.cc
@@ -100,9 +100,8 @@ int utl_strucmp(const char* p_s, const char* p_t) {
/* if p_t hit null first, no match */
if (*p_t == 0 && *p_s != 0) {
return 1;
- }
- /* else p_s hit null first, count as match */
- else {
+ } else {
+ /* else p_s hit null first, count as match */
return 0;
}
}
diff --git a/system/stack/acl/btm_acl.cc b/system/stack/acl/btm_acl.cc
index fecf7b9547..16911e9cc5 100644
--- a/system/stack/acl/btm_acl.cc
+++ b/system/stack/acl/btm_acl.cc
@@ -567,9 +567,8 @@ tBTM_STATUS BTM_SwitchRoleToCentral(const RawAddress& remote_bd_addr) {
return tBTM_STATUS::BTM_WRONG_MODE;
}
p_acl->set_switch_role_changing();
- }
- /* some devices do not support switch while encryption is on */
- else {
+ } else {
+ /* some devices do not support switch while encryption is on */
if (p_acl->is_encrypted && !IsEprAvailable(*p_acl)) {
/* bypass turning off encryption if change link key is already doing it */
p_acl->set_encryption_off();
@@ -630,9 +629,8 @@ void btm_acl_encrypt_change(uint16_t handle, uint8_t /* status */, uint8_t encr_
p->set_switch_role_switching();
}
internal_.hci_start_role_switch_to_central(*p);
- }
- /* Finished enabling Encryption after role switch */
- else if (p->is_switch_role_encryption_on()) {
+ } else if (p->is_switch_role_encryption_on()) {
+ /* Finished enabling Encryption after role switch */
p->reset_switch_role();
p->set_encryption_idle();
NotifyAclRoleSwitchComplete(btm_cb.acl_cb_.switch_role_ref_data.remote_bd_addr,
@@ -1976,16 +1974,14 @@ void btm_cont_rswitch_from_handle(uint16_t hci_handle) {
change of link key or role switch */
if (p->is_switch_role_mode_change()) {
/* Must turn off Encryption first if necessary */
- /* Some devices do not support switch or change of link key while encryption
- * is on */
+ /* Some devices do not support switch or change of link key while encryption is on */
if (p->is_encrypted && !IsEprAvailable(*p)) {
p->set_encryption_off();
if (p->is_switch_role_mode_change()) {
p->set_switch_role_encryption_off();
}
- } else /* Encryption not used or EPR supported, continue with switch
- and/or change of link key */
- {
+ } else {
+ /* Encryption not used or EPR supported, continue with switch and/or change of link key */
if (p->is_switch_role_mode_change()) {
internal_.hci_start_role_switch_to_central(*p);
}
diff --git a/system/stack/avct/avct_api.cc b/system/stack/avct/avct_api.cc
index 55c7cd02e7..82f9f914ba 100644
--- a/system/stack/avct/avct_api.cc
+++ b/system/stack/avct/avct_api.cc
@@ -163,9 +163,8 @@ uint16_t AVCT_CreateConn(uint8_t* p_handle, tAVCT_CC* p_cc, const RawAddress& pe
avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL);
result = AVCT_NO_RESOURCES;
}
- }
- /* check if PID already in use */
- else if (avct_lcb_has_pid(p_lcb, p_cc->pid)) {
+ } else if (avct_lcb_has_pid(p_lcb, p_cc->pid)) {
+ /* check if PID already in use */
avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL);
result = AVCT_PID_IN_USE;
}
@@ -405,9 +404,8 @@ uint16_t AVCT_MsgReq(uint8_t handle, uint8_t label, uint8_t cr, BT_HDR* p_msg) {
if (p_ccb == NULL) {
result = AVCT_BAD_HANDLE;
osi_free(p_msg);
- }
- /* verify channel is bound to link */
- else if (p_ccb->p_lcb == NULL) {
+ } else if (p_ccb->p_lcb == NULL) {
+ /* verify channel is bound to link */
result = AVCT_NOT_OPEN;
osi_free(p_msg);
}
@@ -430,9 +428,8 @@ uint16_t AVCT_MsgReq(uint8_t handle, uint8_t label, uint8_t cr, BT_HDR* p_msg) {
avct_lcb_evt.ul_msg = ul_msg;
avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_MSG_EVT, &avct_lcb_evt);
}
- }
- /* send msg event to lcb */
- else {
+ } else {
+ /* send msg event to lcb */
tAVCT_LCB_EVT avct_lcb_evt;
avct_lcb_evt.ul_msg = ul_msg;
avct_lcb_event(p_ccb->p_lcb, AVCT_LCB_UL_MSG_EVT, &avct_lcb_evt);
diff --git a/system/stack/avct/avct_lcb_act.cc b/system/stack/avct/avct_lcb_act.cc
index 986bce7d34..644449ce88 100644
--- a/system/stack/avct/avct_lcb_act.cc
+++ b/system/stack/avct/avct_lcb_act.cc
@@ -77,9 +77,8 @@ static BT_HDR* avct_lcb_msg_asmbl(tAVCT_LCB* p_lcb, BT_HDR* p_buf) {
osi_free(p_buf);
log::warn("Bad length during reassembly");
p_ret = NULL;
- }
- /* single packet */
- else if (pkt_type == AVCT_PKT_TYPE_SINGLE) {
+ } else if (pkt_type == AVCT_PKT_TYPE_SINGLE) {
+ /* single packet */
/* if reassembly in progress drop message and process new single */
if (p_lcb->p_rx_msg != NULL) {
log::warn("Got single during reassembly");
@@ -88,9 +87,8 @@ static BT_HDR* avct_lcb_msg_asmbl(tAVCT_LCB* p_lcb, BT_HDR* p_buf) {
osi_free_and_reset((void**)&p_lcb->p_rx_msg);
p_ret = p_buf;
- }
- /* start packet */
- else if (pkt_type == AVCT_PKT_TYPE_START) {
+ } else if (pkt_type == AVCT_PKT_TYPE_START) {
+ /* start packet */
/* if reassembly in progress drop message and process new start */
if (p_lcb->p_rx_msg != NULL) {
log::warn("Got start during reassembly");
@@ -127,9 +125,8 @@ static BT_HDR* avct_lcb_msg_asmbl(tAVCT_LCB* p_lcb, BT_HDR* p_buf) {
p_lcb->p_rx_msg->len -= 1;
p_ret = NULL;
- }
- /* continue or end */
- else {
+ } else {
+ /* continue or end */
/* if no reassembly in progress drop message */
if (p_lcb->p_rx_msg == NULL) {
osi_free(p_buf);
@@ -266,12 +263,10 @@ void avct_lcb_open_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data) {
}
p_ccb->cc.p_ctrl_cback(avct_ccb_to_idx(p_ccb), AVCT_CONNECT_CFM_EVT, 0,
&p_lcb->peer_addr);
- }
- /* if unbound acceptor and lcb doesn't already have a ccb for this PID
- */
- /** M: to avoid avctp collision, make sure the collision can be checked
- @{ */
- else if ((p_ccb->cc.role == AVCT_ROLE_ACCEPTOR) && avct_lcb_has_pid(p_lcb, p_ccb->cc.pid)) {
+ } else if ((p_ccb->cc.role == AVCT_ROLE_ACCEPTOR) &&
+ avct_lcb_has_pid(p_lcb, p_ccb->cc.pid)) {
+ /* if unbound acceptor and lcb doesn't already have a ccb for this PID */
+ /* to avoid avctp collision, make sure the collision can be checked */
/* bind ccb to lcb and send connect ind event */
if (is_originater) {
log::error("int exist, unbind acp handle:{}", i);
@@ -304,11 +299,9 @@ void avct_lcb_open_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data) {
}
p_ccb->cc.p_ctrl_cback(avct_ccb_to_idx(p_ccb), AVCT_CONNECT_CFM_EVT, 0,
&p_lcb->peer_addr);
- }
- /* if unbound acceptor and lcb doesn't already have a ccb for this PID
- */
- else if ((p_ccb->p_lcb == NULL) && (p_ccb->cc.role == AVCT_ROLE_ACCEPTOR) &&
- (avct_lcb_has_pid(p_lcb, p_ccb->cc.pid) == NULL)) {
+ } else if ((p_ccb->p_lcb == NULL) && (p_ccb->cc.role == AVCT_ROLE_ACCEPTOR) &&
+ (avct_lcb_has_pid(p_lcb, p_ccb->cc.pid) == NULL)) {
+ /* if unbound acceptor and lcb doesn't already have a ccb for this PID */
/* bind ccb to lcb and send connect ind event */
bind = true;
p_ccb->p_lcb = p_lcb;
@@ -615,10 +608,8 @@ void avct_lcb_send_msg(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data) {
if (p_lcb->cong) {
fixed_queue_enqueue(p_lcb->tx_q, p_buf);
- }
-
- /* send message to L2CAP */
- else {
+ } else {
+ /* send message to L2CAP */
if (stack::l2cap::get_interface().L2CA_DataWrite(p_lcb->ch_lcid, p_buf) ==
tL2CAP_DW_RESULT::CONGESTED) {
p_lcb->cong = true;
diff --git a/system/stack/avdt/avdt_api.cc b/system/stack/avdt/avdt_api.cc
index 6304e78255..f4866fc84d 100644
--- a/system/stack/avdt/avdt_api.cc
+++ b/system/stack/avdt/avdt_api.cc
@@ -173,10 +173,8 @@ uint16_t AVDT_CreateStream(uint8_t peer_id, uint8_t* p_handle,
result = AVDT_BAD_PARAMS;
log::error("Invalid AVDT stream endpoint parameters peer_id={} scb_index={}", peer_id,
avdtp_stream_config.scb_index);
- }
-
- /* Allocate scb; if no scbs, return failure */
- else {
+ } else {
+ /* Allocate scb; if no scbs, return failure */
p_scb = avdt_scb_alloc(peer_id, avdtp_stream_config);
if (p_scb == NULL) {
log::error("Unable to create AVDT stream endpoint peer_id={} scb_index={}", peer_id,
@@ -274,9 +272,8 @@ uint16_t AVDT_DiscoverReq(const RawAddress& bd_addr, uint8_t channel_index,
/* make sure no discovery or get capabilities req already in progress */
if (p_ccb->proc_busy) {
result = AVDT_BUSY;
- }
- /* send event to ccb */
- else {
+ } else {
+ /* send event to ccb */
evt.discover.p_sep_info = p_sep_info;
evt.discover.num_seps = max_seps;
evt.discover.p_cback = p_cback;
@@ -308,9 +305,8 @@ static uint16_t avdt_get_cap_req(const RawAddress& bd_addr, uint8_t channel_inde
if ((p_evt->single.seid < AVDT_SEID_MIN) || (p_evt->single.seid > AVDT_SEID_MAX)) {
log::error("seid: {}", p_evt->single.seid);
result = AVDT_BAD_PARAMS;
- }
- /* find channel control block for this bd addr; if none, allocate one */
- else {
+ } else {
+ /* find channel control block for this bd addr; if none, allocate one */
p_ccb = avdt_ccb_by_bd(bd_addr);
if (p_ccb == NULL) {
p_ccb = avdt_ccb_alloc_by_channel_index(bd_addr, channel_index);
@@ -325,9 +321,8 @@ static uint16_t avdt_get_cap_req(const RawAddress& bd_addr, uint8_t channel_inde
/* make sure no discovery or get capabilities req already in progress */
if (p_ccb->proc_busy) {
result = AVDT_BUSY;
- }
- /* send event to ccb */
- else {
+ } else {
+ /* send event to ccb */
avdt_ccb_event(p_ccb, AVDT_CCB_API_GETCAP_REQ_EVT, (tAVDT_CCB_EVT*)p_evt);
}
}
@@ -448,15 +443,13 @@ uint16_t AVDT_OpenReq(uint8_t handle, const RawAddress& bd_addr, uint8_t channel
/* verify SEID */
if ((seid < AVDT_SEID_MIN) || (seid > AVDT_SEID_MAX)) {
result = AVDT_BAD_PARAMS;
- }
- /* map handle to scb */
- else {
+ } else {
+ /* map handle to scb */
p_scb = avdt_scb_by_hdl(handle);
if (p_scb == NULL) {
result = AVDT_BAD_HANDLE;
- }
- /* find channel control block for this bd addr; if none, allocate one */
- else {
+ } else {
+ /* find channel control block for this bd addr; if none, allocate one */
p_ccb = avdt_ccb_by_bd(bd_addr);
if (p_ccb == NULL) {
p_ccb = avdt_ccb_alloc_by_channel_index(bd_addr, channel_index);
@@ -509,15 +502,12 @@ uint16_t AVDT_ConfigRsp(uint8_t handle, uint8_t label, uint8_t error_code, uint8
p_scb = avdt_scb_by_hdl(handle);
if (p_scb == NULL) {
result = AVDT_BAD_HANDLE;
- }
- /* handle special case when this function is called but peer has not send
- ** a configuration cmd; ignore and return error result
- */
- else if (!p_scb->in_use) {
+ } else if (!p_scb->in_use) {
+ /* handle special case when this function is called but peer has not send
+ * a configuration cmd; ignore and return error result */
result = AVDT_BAD_HANDLE;
- }
- /* send event to scb */
- else {
+ } else {
+ /* send event to scb */
evt.msg.hdr.err_code = error_code;
evt.msg.hdr.err_param = category;
evt.msg.hdr.label = label;
@@ -715,9 +705,8 @@ uint16_t AVDT_ReconfigReq(uint8_t handle, AvdtpSepConfig* p_cfg) {
p_scb = avdt_scb_by_hdl(handle);
if (p_scb == NULL) {
result = AVDT_BAD_HANDLE;
- }
- /* send event to scb */
- else {
+ } else {
+ /* send event to scb */
/* force psc_mask to zero */
p_cfg->psc_mask = 0;
evt.msg.reconfig_cmd.p_cfg = p_cfg;
@@ -755,9 +744,8 @@ uint16_t AVDT_SecurityReq(uint8_t handle, uint8_t* p_data, uint16_t len) {
p_scb = avdt_scb_by_hdl(handle);
if (p_scb == NULL) {
result = AVDT_BAD_HANDLE;
- }
- /* send event to scb */
- else {
+ } else {
+ /* send event to scb */
evt.msg.security_rsp.p_data = p_data;
evt.msg.security_rsp.len = len;
avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_REQ_EVT, &evt);
@@ -795,9 +783,8 @@ uint16_t AVDT_SecurityRsp(uint8_t handle, uint8_t label, uint8_t error_code, uin
p_scb = avdt_scb_by_hdl(handle);
if (p_scb == NULL) {
result = AVDT_BAD_HANDLE;
- }
- /* send event to scb */
- else {
+ } else {
+ /* send event to scb */
evt.msg.security_rsp.hdr.err_code = error_code;
evt.msg.security_rsp.hdr.label = label;
evt.msg.security_rsp.p_data = p_data;
diff --git a/system/stack/avdt/avdt_ccb_act.cc b/system/stack/avdt/avdt_ccb_act.cc
index df905c1e79..05e064f230 100644
--- a/system/stack/avdt/avdt_ccb_act.cc
+++ b/system/stack/avdt/avdt_ccb_act.cc
@@ -830,9 +830,8 @@ void avdt_ccb_snd_msg(AvdtpCcb* p_ccb, tAVDT_CCB_EVT* /* p_data */) {
/* are we sending a fragmented message? continue sending fragment */
if (p_ccb->p_curr_msg != NULL) {
avdt_msg_send(p_ccb, NULL);
- }
- /* do we have responses to send? send them */
- else if (!fixed_queue_is_empty(p_ccb->rsp_q)) {
+ } else if (!fixed_queue_is_empty(p_ccb->rsp_q)) {
+ /* do we have responses to send? send them */
while ((p_msg = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL) {
if (avdt_msg_send(p_ccb, p_msg)) {
/* break out if congested */
diff --git a/system/stack/avdt/avdt_msg.cc b/system/stack/avdt/avdt_msg.cc
index 4241cd741a..70a8c4770e 100644
--- a/system/stack/avdt/avdt_msg.cc
+++ b/system/stack/avdt/avdt_msg.cc
@@ -1064,10 +1064,9 @@ bool avdt_msg_send(AvdtpCcb* p_ccb, BT_HDR* p_msg) {
pkt_type = AVDT_PKT_TYPE_SINGLE;
hdr_len = AVDT_LEN_TYPE_SINGLE;
p_buf = p_ccb->p_curr_msg;
- }
- /* if message isn't being fragmented and it doesn't fit in mtu */
- else if ((p_ccb->p_curr_msg->offset == AVDT_MSG_OFFSET) &&
- (p_ccb->p_curr_msg->len > p_tbl->peer_mtu - AVDT_LEN_TYPE_SINGLE)) {
+ } else if ((p_ccb->p_curr_msg->offset == AVDT_MSG_OFFSET) &&
+ /* if message isn't being fragmented and it doesn't fit in mtu */
+ (p_ccb->p_curr_msg->len > p_tbl->peer_mtu - AVDT_LEN_TYPE_SINGLE)) {
pkt_type = AVDT_PKT_TYPE_START;
hdr_len = AVDT_LEN_TYPE_START;
nosp = (p_ccb->p_curr_msg->len + AVDT_LEN_TYPE_START - p_tbl->peer_mtu) /
@@ -1082,10 +1081,9 @@ bool avdt_msg_send(AvdtpCcb* p_ccb, BT_HDR* p_msg) {
p_buf->len = p_tbl->peer_mtu - hdr_len;
memcpy((uint8_t*)(p_buf + 1) + p_buf->offset,
(uint8_t*)(p_ccb->p_curr_msg + 1) + p_ccb->p_curr_msg->offset, p_buf->len);
- }
- /* if message is being fragmented and remaining bytes don't fit in mtu */
- else if ((p_ccb->p_curr_msg->offset > AVDT_MSG_OFFSET) &&
- (p_ccb->p_curr_msg->len > (p_tbl->peer_mtu - AVDT_LEN_TYPE_CONT))) {
+ } else if ((p_ccb->p_curr_msg->offset > AVDT_MSG_OFFSET) &&
+ /* if message is being fragmented and remaining bytes don't fit in mtu */
+ (p_ccb->p_curr_msg->len > (p_tbl->peer_mtu - AVDT_LEN_TYPE_CONT))) {
pkt_type = AVDT_PKT_TYPE_CONT;
hdr_len = AVDT_LEN_TYPE_CONT;
@@ -1097,9 +1095,8 @@ bool avdt_msg_send(AvdtpCcb* p_ccb, BT_HDR* p_msg) {
p_buf->len = p_tbl->peer_mtu - hdr_len;
memcpy((uint8_t*)(p_buf + 1) + p_buf->offset,
(uint8_t*)(p_ccb->p_curr_msg + 1) + p_ccb->p_curr_msg->offset, p_buf->len);
- }
- /* if message is being fragmented and remaining bytes do fit in mtu */
- else {
+ } else {
+ /* if message is being fragmented and remaining bytes do fit in mtu */
pkt_type = AVDT_PKT_TYPE_END;
hdr_len = AVDT_LEN_TYPE_END;
p_buf = p_ccb->p_curr_msg;
@@ -1193,9 +1190,8 @@ static BT_HDR* avdt_msg_asmbl(AvdtpCcb* p_ccb, BT_HDR* p_buf) {
osi_free(p_buf);
log::warn("Bad length during reassembly");
p_ret = NULL;
- }
- /* single packet */
- else if (pkt_type == AVDT_PKT_TYPE_SINGLE) {
+ } else if (pkt_type == AVDT_PKT_TYPE_SINGLE) {
+ /* single packet */
/* if reassembly in progress drop message and process new single */
if (p_ccb->p_rx_msg != NULL) {
log::warn("Got single during reassembly");
@@ -1204,9 +1200,8 @@ static BT_HDR* avdt_msg_asmbl(AvdtpCcb* p_ccb, BT_HDR* p_buf) {
osi_free_and_reset((void**)&p_ccb->p_rx_msg);
p_ret = p_buf;
- }
- /* start packet */
- else if (pkt_type == AVDT_PKT_TYPE_START) {
+ } else if (pkt_type == AVDT_PKT_TYPE_START) {
+ /* start packet */
/* if reassembly in progress drop message and process new single */
if (p_ccb->p_rx_msg != NULL) {
log::warn("Got start during reassembly");
@@ -1243,9 +1238,8 @@ static BT_HDR* avdt_msg_asmbl(AvdtpCcb* p_ccb, BT_HDR* p_buf) {
p_ccb->p_rx_msg->len -= 1;
p_ret = NULL;
- }
- /* continue or end */
- else {
+ } else {
+ /* continue or end */
/* if no reassembly in progress drop message */
if (p_ccb->p_rx_msg == NULL) {
osi_free(p_buf);
@@ -1329,9 +1323,8 @@ void avdt_msg_send_cmd(AvdtpCcb* p_ccb, void* p_scb, uint8_t sig_id, tAVDT_MSG*
/* for start and suspend, p_scb points to array of handles */
if ((sig_id == AVDT_SIG_START) || (sig_id == AVDT_SIG_SUSPEND)) {
memcpy(p, (uint8_t*)p_scb, p_buf->len);
- }
- /* for all others, p_scb points to scb as usual */
- else {
+ } else {
+ /* for all others, p_scb points to scb as usual */
*p = avdt_scb_to_hdl((AvdtpScb*)p_scb);
}
}
@@ -1523,9 +1516,8 @@ void avdt_msg_ind(AvdtpCcb* p_ccb, BT_HDR* p_buf) {
if (msg_type == AVDT_MSG_TYPE_GRJ) {
log::warn("Dropping msg msg_type={}", msg_type);
ok = false;
- }
- /* check for general reject */
- else if ((msg_type == AVDT_MSG_TYPE_REJ) && (p_buf->len == AVDT_LEN_GEN_REJ)) {
+ } else if ((msg_type == AVDT_MSG_TYPE_REJ) && (p_buf->len == AVDT_LEN_GEN_REJ)) {
+ /* check for general reject */
gen_rej = true;
if (p_ccb->p_curr_cmd != NULL) {
msg.hdr.sig_id = sig = (uint8_t)p_ccb->p_curr_cmd->event;
@@ -1633,9 +1625,8 @@ void avdt_msg_ind(AvdtpCcb* p_ccb, BT_HDR* p_buf) {
tAVDT_CCB_EVT avdt_ccb_evt;
avdt_ccb_evt.msg = msg;
avdt_ccb_event(p_ccb, (uint8_t)(evt & ~AVDT_CCB_MKR), &avdt_ccb_evt);
- }
- /* if it's a scb event */
- else {
+ } else {
+ /* if it's a scb event */
/* Scb events always have a single seid. For cmd, get seid from
** message. For rej and rsp, get seid from p_curr_cmd.
*/
diff --git a/system/stack/avdt/avdt_scb_act.cc b/system/stack/avdt/avdt_scb_act.cc
index d16f963ab1..007607674c 100644
--- a/system/stack/avdt/avdt_scb_act.cc
+++ b/system/stack/avdt/avdt_scb_act.cc
@@ -276,9 +276,8 @@ void avdt_scb_hdl_pkt_no_frag(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) {
if (pad_len >= (len - offset)) {
log::warn("Got bad media packet");
osi_free_and_reset((void**)&p_data->p_pkt);
- }
- /* adjust offset and length and send it up */
- else {
+ } else {
+ /* adjust offset and length and send it up */
p_data->p_pkt->len -= (offset + pad_len);
p_data->p_pkt->offset += offset;
diff --git a/system/stack/avrc/avrc_api.cc b/system/stack/avrc/avrc_api.cc
index ea82921b43..88a7215377 100644
--- a/system/stack/avrc/avrc_api.cc
+++ b/system/stack/avrc/avrc_api.cc
@@ -386,9 +386,8 @@ static BT_HDR* avrc_proc_vendor_command(uint8_t handle, uint8_t label, BT_HDR* p
log::error("commands must be in single packet pdu:0x{:x}", *p_data);
/* use the current GKI buffer to send the reject */
status = AVRC_STS_BAD_CMD;
- }
- /* check if there are fragments waiting to be sent */
- else if (avrc_cb.fcb[handle].frag_enabled) {
+ } else if (avrc_cb.fcb[handle].frag_enabled) {
+ /* check if there are fragments waiting to be sent */
p_fcb = &avrc_cb.fcb[handle];
if (p_msg->company_id == AVRC_CO_METADATA) {
switch (*p_data) {
diff --git a/system/stack/btm/btm_ble_adv_filter.cc b/system/stack/btm/btm_ble_adv_filter.cc
index 3e6520ebc2..73050b5047 100644
--- a/system/stack/btm/btm_ble_adv_filter.cc
+++ b/system/stack/btm/btm_ble_adv_filter.cc
@@ -285,10 +285,8 @@ static uint8_t btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action, uint8_
(BTM_BLE_PF_ADDR_FILTER == cond_type &&
(BTM_BLE_SCAN_COND_DELETE == action || BTM_BLE_SCAN_COND_CLEAR == action))) {
btm_ble_dealloc_addr_filter_counter(p_bd_addr, cond_type);
- }
- /* if not feature selection, update new addition/reduction of the filter
- counter */
- else if (cond_type != BTM_BLE_PF_TYPE_ALL) {
+ } else if (cond_type != BTM_BLE_PF_TYPE_ALL) {
+ /* if not feature selection, update new addition/reduction of the filter counter */
p_counter = p_addr_filter->pf_counter;
if (num_available > 0) {
p_counter[cond_type] += 1;
diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc
index 9b86ae9eca..25ace16aca 100644
--- a/system/stack/btm/btm_ble_gap.cc
+++ b/system/stack/btm/btm_ble_gap.cc
@@ -1176,11 +1176,9 @@ static uint8_t btm_set_conn_mode_adv_init_addr(RawAddress& p_peer_addr_ptr,
/* resolving list is empty, not enabled */
*p_own_addr_type = BLE_ADDR_RANDOM;
}
- }
- /* privacy 1.1, or privacy 1.2, general discoverable/connectable mode, disable
- privacy in */
- /* controller fall back to host based privacy */
- else if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
+ } else if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
+ /* privacy 1.1, or privacy 1.2, general discoverable/connectable mode, disable privacy in */
+ /* controller fall back to host based privacy */
*p_own_addr_type = BLE_ADDR_RANDOM;
}
diff --git a/system/stack/btm/btm_ble_sec.cc b/system/stack/btm/btm_ble_sec.cc
index 9927751bb1..a48e283511 100644
--- a/system/stack/btm/btm_ble_sec.cc
+++ b/system/stack/btm/btm_ble_sec.cc
@@ -1325,9 +1325,8 @@ void btm_ble_link_encrypted(const RawAddress& bd_addr, uint8_t encr_enable) {
if (p_dev_rec->sec_rec.p_callback && enc_cback) {
if (encr_enable) {
btm_sec_dev_rec_cback_event(p_dev_rec, tBTM_STATUS::BTM_SUCCESS, true);
- }
- /* LTK missing on peripheral */
- else if (p_dev_rec->role_central && (p_dev_rec->sec_rec.sec_status == HCI_ERR_KEY_MISSING)) {
+ } else if (p_dev_rec->role_central && (p_dev_rec->sec_rec.sec_status == HCI_ERR_KEY_MISSING)) {
+ /* LTK missing on peripheral */
btm_sec_dev_rec_cback_event(p_dev_rec, tBTM_STATUS::BTM_ERR_KEY_MISSING, true);
} else if (!(p_dev_rec->sec_rec.sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN)) {
btm_sec_dev_rec_cback_event(p_dev_rec, tBTM_STATUS::BTM_FAILED_ON_SECURITY, true);
diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc
index dc7ba92ce5..52ef73f682 100644
--- a/system/stack/btm/btm_sec.cc
+++ b/system/stack/btm/btm_sec.cc
@@ -622,9 +622,8 @@ void BTM_PINCodeReply(const RawAddress& bd_addr, tBTM_STATUS res, uint8_t pin_le
* connection */
/* when existing ACL link is down completely */
btm_sec_cb.change_pairing_state(BTM_PAIR_STATE_WAIT_PIN_REQ);
- }
- /* if we already accepted incoming connection from pairing device */
- else if (p_dev_rec->sm4 & BTM_SM4_CONN_PEND) {
+ } else if (p_dev_rec->sm4 & BTM_SM4_CONN_PEND) {
+ /* if we already accepted incoming connection from pairing device */
log::warn(
"BTM_PINCodeReply(): link is connecting so wait pin code request "
"from peer");
@@ -2327,9 +2326,8 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr, const uint8_
/* before originating */
if (btm_sec_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) {
log::warn("waiting HCI_Connection_Complete after rejecting connection");
- }
- /* Both we and the peer are 2.1 - continue to create connection */
- else {
+ } else {
+ /* Both we and the peer are 2.1 - continue to create connection */
tBTM_STATUS req_status = btm_sec_dd_create_conn(p_dev_rec);
bluetooth::metrics::LogAclAfterRemoteNameRequest(bd_addr, req_status);
if (req_status == tBTM_STATUS::BTM_SUCCESS) {
@@ -3638,20 +3636,19 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, tHCI_STATUS statu
/* We need to notify host that the key is not known any more */
NotifyBondingChange(*p_dev_rec, status);
- }
- /*
- Do not send authentication failure, if following conditions hold good
- 1. BTM Sec Pairing state is idle
- 2. Link key for the remote device is present.
- 3. Remote is SSP capable.
- */
- else if ((p_dev_rec->sec_rec.link_key_type <= BTM_LKEY_TYPE_REMOTE_UNIT) &&
- ((status == HCI_ERR_AUTH_FAILURE) || (status == HCI_ERR_KEY_MISSING) ||
- (status == HCI_ERR_HOST_REJECT_SECURITY) || (status == HCI_ERR_PAIRING_NOT_ALLOWED) ||
- (status == HCI_ERR_UNIT_KEY_USED) ||
- (status == HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED) ||
- (status == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) ||
- (status == HCI_ERR_REPEATED_ATTEMPTS))) {
+ } else if ((p_dev_rec->sec_rec.link_key_type <= BTM_LKEY_TYPE_REMOTE_UNIT) &&
+ ((status == HCI_ERR_AUTH_FAILURE) || (status == HCI_ERR_KEY_MISSING) ||
+ (status == HCI_ERR_HOST_REJECT_SECURITY) ||
+ (status == HCI_ERR_PAIRING_NOT_ALLOWED) || (status == HCI_ERR_UNIT_KEY_USED) ||
+ (status == HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED) ||
+ (status == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) ||
+ (status == HCI_ERR_REPEATED_ATTEMPTS))) {
+ /*
+ Do not send authentication failure, if following conditions hold good
+ 1. BTM Sec Pairing state is idle
+ 2. Link key for the remote device is present.
+ 3. Remote is SSP capable.
+ */
p_dev_rec->sec_rec.security_required &= ~BTM_SEC_OUT_AUTHENTICATE;
p_dev_rec->sec_rec.sec_flags &= ~(BTM_SEC_LE_LINK_KEY_KNOWN << bit_shift);
@@ -4336,31 +4333,23 @@ void btm_sec_pin_code_request(const RawAddress p_bda) {
btm_restore_mode(); */
btm_sec_cb.change_pairing_state(BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
- }
-
- /* If pairing disabled OR (no PIN callback and not bonding) */
- /* OR we could not allocate entry in the database reject pairing request */
- else if (p_cb->pairing_disabled ||
- (p_cb->api.p_pin_callback == NULL)
-
- /* OR Microsoft keyboard can for some reason try to establish
- * connection
- */
- /* the only thing we can do here is to shut it up. Normally we will
- be originator */
- /* for keyboard bonding */
- || (!p_dev_rec->IsLocallyInitiated() &&
- ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == BTM_COD_MAJOR_PERIPHERAL) &&
- (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD))) {
+ } else if (p_cb->pairing_disabled || (p_cb->api.p_pin_callback == NULL) ||
+ (!p_dev_rec->IsLocallyInitiated() &&
+ ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == BTM_COD_MAJOR_PERIPHERAL) &&
+ (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD))) {
+ /* If pairing disabled
+ * OR no PIN callback and not bonding
+ * OR we could not allocate entry in the database reject pairing request
+ * OR Microsoft keyboard can for some reason try to establish connection the only thing we can
+ * do here is to shut it up. Normally we will be originator for keyboard bonding */
log::warn(
"btm_sec_pin_code_request(): Pairing disabled:{}; PIN callback:{}, Dev "
"Rec:{}!",
p_cb->pairing_disabled, fmt::ptr(p_cb->api.p_pin_callback), fmt::ptr(p_dev_rec));
btsnd_hcic_pin_code_neg_reply(p_bda);
- }
- /* Notify upper layer of PIN request and start expiration timer */
- else {
+ } else {
+ /* Notify upper layer of PIN request and start expiration timer */
btm_sec_cb.change_pairing_state(BTM_PAIR_STATE_WAIT_LOCAL_PIN);
/* Pin code request can not come at the same time as connection request */
p_cb->connecting_bda = p_bda;
diff --git a/system/stack/btm/btm_sec_cb.cc b/system/stack/btm/btm_sec_cb.cc
index 60a2f0398e..ac86e7f5b7 100644
--- a/system/stack/btm/btm_sec_cb.cc
+++ b/system/stack/btm/btm_sec_cb.cc
@@ -230,9 +230,8 @@ bool tBTM_SEC_CB::AddService(bool is_originator, const char* p_name, uint8_t ser
record_allocated = true;
break;
}
- }
- /* Mark the first available service record */
- else if (!record_allocated) {
+ } else if (!record_allocated) {
+ /* Mark the first available service record */
*p_srec = {};
record_allocated = true;
first_unused_record = index;
diff --git a/system/stack/gatt/gatt_cl.cc b/system/stack/gatt/gatt_cl.cc
index 50844962f4..6093d572ee 100644
--- a/system/stack/gatt/gatt_cl.cc
+++ b/system/stack/gatt/gatt_cl.cc
@@ -884,10 +884,9 @@ static void gatt_process_read_by_type_rsp(tGATT_TCB& tcb, tGATT_CLCB* p_clcb, ui
break;
}
}
- }
- /* discover included service */
- else if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY &&
- p_clcb->op_subtype == GATT_DISC_INC_SRVC) {
+ } else if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY &&
+ p_clcb->op_subtype == GATT_DISC_INC_SRVC) {
+ /* discover included service */
if (value_len < 4) {
log::error("Illegal Response length, must be at least 4.");
gatt_end_operation(p_clcb, GATT_INVALID_PDU, NULL);
@@ -920,9 +919,8 @@ static void gatt_process_read_by_type_rsp(tGATT_TCB& tcb, tGATT_CLCB* p_clcb, ui
gatt_end_operation(p_clcb, GATT_INVALID_PDU, (void*)p);
return;
}
- }
- /* read by type */
- else if (p_clcb->operation == GATTC_OPTYPE_READ && p_clcb->op_subtype == GATT_READ_BY_TYPE) {
+ } else if (p_clcb->operation == GATTC_OPTYPE_READ && p_clcb->op_subtype == GATT_READ_BY_TYPE) {
+ /* read by type */
p_clcb->counter = len - 2;
p_clcb->s_handle = handle;
diff --git a/system/stack/gatt/gatt_db.cc b/system/stack/gatt/gatt_db.cc
index cd55ffdb71..9dd73128b5 100644
--- a/system/stack/gatt/gatt_db.cc
+++ b/system/stack/gatt/gatt_db.cc
@@ -55,7 +55,7 @@ void gatts_init_service_db(tGATT_SVC_DB& db, const Uuid& service_uuid, bool is_p
db.next_handle = s_hdl;
db.end_handle = s_hdl + num_handle;
- /* add service declration record */
+ /* add service declaration record */
Uuid uuid = Uuid::From16Bit(is_pri ? GATT_UUID_PRI_SERVICE : GATT_UUID_SEC_SERVICE);
tGATT_ATTR& attr = allocate_attr_in_db(db, uuid, GATT_PERM_READ);
attr.p_value.reset(new tGATT_ATTR_VALUE);
@@ -360,7 +360,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, uint16_
* Function gatts_add_characteristic
*
* Description This function add a characteristics and its descriptor into
- * a servce identified by the service database pointer.
+ * a service identified by the service database pointer.
*
* Parameter db: database.
* perm: permission (authentication and key size requirements)
@@ -568,12 +568,11 @@ tGATT_STATUS gatts_write_attr_perm_check(tGATT_SVC_DB* p_db, uint8_t op_code, ui
/* LE security mode 2 level 1 and LE security mode 1 level 2 */
if ((perm & GATT_PERM_WRITE_SIGNED) && (perm & GATT_PERM_WRITE_ENCRYPTED)) {
perm = GATT_PERM_WRITE_ENCRYPTED;
- }
- /* use security mode 1 level 3 when the following condition follows */
- /* LE security mode 2 level 2 and security mode 1 and LE */
- else if (((perm & GATT_PERM_WRITE_SIGNED_MITM) && (perm & GATT_PERM_WRITE_ENCRYPTED)) ||
- /* LE security mode 2 and security mode 1 level 3 */
- ((perm & GATT_WRITE_SIGNED_PERM) && (perm & GATT_PERM_WRITE_ENC_MITM))) {
+ } else if (((perm & GATT_PERM_WRITE_SIGNED_MITM) && (perm & GATT_PERM_WRITE_ENCRYPTED)) ||
+ ((perm & GATT_WRITE_SIGNED_PERM) && (perm & GATT_PERM_WRITE_ENC_MITM))) {
+ /* use security mode 1 level 3 when the following condition follows */
+ /* LE security mode 2 level 2 and security mode 1 and LE */
+ /* LE security mode 2 and security mode 1 level 3 */
perm = GATT_PERM_WRITE_ENC_MITM;
}
}
@@ -585,13 +584,12 @@ tGATT_STATUS gatts_write_attr_perm_check(tGATT_SVC_DB* p_db, uint8_t op_code, ui
}
if ((op_code == GATT_SIGN_CMD_WRITE) && sec_flag.is_encrypted) {
status = GATT_INVALID_PDU;
- log::error("Error!! sign cmd write sent on a encypted link");
+ log::error("Error!! sign cmd write sent on a encrypted link");
} else if (!(perm & GATT_WRITE_ALLOWED)) {
status = GATT_WRITE_NOT_PERMIT;
log::error("GATT_WRITE_NOT_PERMIT");
- }
- /* require authentication, but not been authenticated */
- else if ((perm & GATT_WRITE_AUTH_REQUIRED) && !sec_flag.is_link_key_known) {
+ } else if ((perm & GATT_WRITE_AUTH_REQUIRED) && !sec_flag.is_link_key_known) {
+ /* require authentication, but not been authenticated */
status = GATT_INSUF_AUTHENTICATION;
log::error("GATT_INSUF_AUTHENTICATION");
} else if ((perm & GATT_WRITE_MITM_REQUIRED) && !sec_flag.is_link_key_authed) {
@@ -604,14 +602,13 @@ tGATT_STATUS gatts_write_attr_perm_check(tGATT_SVC_DB* p_db, uint8_t op_code, ui
(key_size < min_key_size)) {
status = GATT_INSUF_KEY_SIZE;
log::error("GATT_INSUF_KEY_SIZE");
- }
- /* LE security mode 2 attribute */
- else if (perm & GATT_WRITE_SIGNED_PERM && op_code != GATT_SIGN_CMD_WRITE &&
- !sec_flag.is_encrypted && (perm & GATT_WRITE_ALLOWED) == 0) {
+ } else if (perm & GATT_WRITE_SIGNED_PERM && op_code != GATT_SIGN_CMD_WRITE &&
+ !sec_flag.is_encrypted && (perm & GATT_WRITE_ALLOWED) == 0) {
+ /* LE security mode 2 attribute */
status = GATT_INSUF_AUTHENTICATION;
log::error("GATT_INSUF_AUTHENTICATION: LE security mode 2 required");
- } else /* writable: must be char value declaration or char descritpors */
- {
+ } else {
+ /* writable: must be char value declaration or char descriptors */
uint16_t max_size = 0;
if (p_attr->uuid.IsEmpty()) {
diff --git a/system/stack/gatt/gatt_main.cc b/system/stack/gatt/gatt_main.cc
index 2cf2c42a51..e530d9fd5e 100644
--- a/system/stack/gatt/gatt_main.cc
+++ b/system/stack/gatt/gatt_main.cc
@@ -533,10 +533,8 @@ static void gatt_le_connect_cback(uint16_t /* chan */, const RawAddress& bd_addr
if (check_srv_chg) {
gatt_chk_srv_chg(p_srv_chg_clt);
}
- }
- /* this is incoming connection or background connection callback */
-
- else {
+ } else {
+ /* this is incoming connection or background connection callback */
p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, BT_TRANSPORT_LE);
if (!p_tcb) {
log::error("Disconnecting address:{} due to out of resources.", bd_addr);
diff --git a/system/stack/hid/hidh_api.cc b/system/stack/hid/hidh_api.cc
index f415c48fb1..eb9e10ad23 100644
--- a/system/stack/hid/hidh_api.cc
+++ b/system/stack/hid/hidh_api.cc
@@ -494,9 +494,7 @@ tHID_STATUS HID_HostWriteDev(uint8_t dev_handle, uint8_t t_type, uint8_t param,
android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_HOST_WRITE_DEV,
1);
status = HID_ERR_INVALID_PARAM;
- }
-
- else if (hh_cb.devices[dev_handle].state != HID_DEV_CONNECTED) {
+ } else if (hh_cb.devices[dev_handle].state != HID_DEV_CONNECTED) {
log::error("HID_ERR_NO_CONNECTION dev_handle {}", dev_handle);
log_counter_metrics(
android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_CONNECTION_AT_HOST_WRITE_DEV,
diff --git a/system/stack/l2cap/l2c_api.cc b/system/stack/l2cap/l2c_api.cc
index b9587454f1..99b0276413 100644
--- a/system/stack/l2cap/l2c_api.cc
+++ b/system/stack/l2cap/l2c_api.cc
@@ -552,15 +552,12 @@ uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr, tL2CAP_
do_in_main_thread(base::BindOnce(&l2c_csm_execute, base::Unretained(p_ccb),
L2CEVT_L2CA_CONNECT_REQ, nullptr));
}
- }
-
- /* If link is disconnecting, save link info to retry after disconnect
- * Possible Race condition when a reconnect occurs
- * on the channel during a disconnect of link. This
- * ccb will be automatically retried after link disconnect
- * arrives
- */
- else if (p_lcb->link_state == LST_DISCONNECTING) {
+ } else if (p_lcb->link_state == LST_DISCONNECTING) {
+ /* If link is disconnecting, save link info to retry after disconnect
+ * Possible Race condition when a reconnect occurs
+ * on the channel during a disconnect of link. This
+ * ccb will be automatically retried after link disconnect
+ * arrives */
log::verbose("link disconnecting: RETRY LATER");
/* Save ccb so it can be started after disconnect is finished */
diff --git a/system/stack/l2cap/l2c_fcr.cc b/system/stack/l2cap/l2c_fcr.cc
index 9b144ec897..b310b37443 100644
--- a/system/stack/l2cap/l2c_fcr.cc
+++ b/system/stack/l2cap/l2c_fcr.cc
@@ -1423,9 +1423,8 @@ BT_HDR* l2c_fcr_get_next_xmit_sdu_seg(tL2C_CCB* p_ccb, uint16_t max_packet_lengt
/* copy PBF setting */
p_xmit->layer_specific = p_buf->layer_specific;
- } else /* Should never happen if the application has configured buffers
- correctly */
- {
+ } else {
+ /* Should never happen if the application has configured buffers correctly */
log::error("L2CAP - cannot get buffer for segmentation, max_pdu: {}", max_pdu);
return NULL;
}
@@ -1794,10 +1793,8 @@ uint8_t l2c_fcr_process_peer_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) {
p_cfg->fcr.tx_win_sz = p_ccb->our_cfg.fcr.tx_win_sz;
p_cfg->fcr.max_transmit = p_ccb->our_cfg.fcr.max_transmit;
fcr_ok = L2CAP_PEER_CFG_UNACCEPTABLE;
- }
-
- /* If we wanted basic, then try to renegotiate it */
- else if (p_ccb->p_rcb->ertm_info.preferred_mode == L2CAP_FCR_BASIC_MODE) {
+ } else if (p_ccb->p_rcb->ertm_info.preferred_mode == L2CAP_FCR_BASIC_MODE) {
+ /* If we wanted basic, then try to renegotiate it */
p_cfg->fcr.mode = L2CAP_FCR_BASIC_MODE;
p_cfg->fcr.max_transmit = p_cfg->fcr.tx_win_sz = 0;
p_cfg->fcr.rtrans_tout = p_cfg->fcr.mon_tout = p_cfg->fcr.mps = 0;
diff --git a/system/stack/l2cap/l2c_link.cc b/system/stack/l2cap/l2c_link.cc
index 3a3bb4290d..a202c36549 100644
--- a/system/stack/l2cap/l2c_link.cc
+++ b/system/stack/l2cap/l2c_link.cc
@@ -134,10 +134,9 @@ void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle, const RawAddres
uint64_t timeout_ms = L2CAP_LINK_STARTUP_TOUT * 1000;
alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, p_lcb);
}
- }
- /* Max number of acl connections. */
- /* If there's an lcb disconnecting set this one to holding */
- else if ((ci.hci_status == HCI_ERR_MAX_NUM_OF_CONNECTIONS) && l2cu_lcb_disconnecting()) {
+ } else if ((ci.hci_status == HCI_ERR_MAX_NUM_OF_CONNECTIONS) && l2cu_lcb_disconnecting()) {
+ /* Max number of acl connections. */
+ /* If there's an lcb disconnecting set this one to holding */
log::warn("Delaying connection as reached max number of links:{}",
HCI_ERR_MAX_NUM_OF_CONNECTIONS);
p_lcb->link_state = LST_CONNECT_HOLDING;
@@ -616,16 +615,14 @@ void l2c_link_adjust_allocation(void) {
if (num_lowpri_links > low_quota) {
l2cb.round_robin_quota = low_quota;
qq = qq_remainder = 1;
- }
- /* If each low priority link can have at least one buffer */
- else if (num_lowpri_links > 0) {
+ } else if (num_lowpri_links > 0) {
+ /* If each low priority link can have at least one buffer */
l2cb.round_robin_quota = 0;
l2cb.round_robin_unacked = 0;
qq = low_quota / num_lowpri_links;
qq_remainder = low_quota % num_lowpri_links;
- }
- /* If no low priority link */
- else {
+ } else {
+ /* If no low priority link */
l2cb.round_robin_quota = 0;
l2cb.round_robin_unacked = 0;
qq = qq_remainder = 1;
@@ -924,9 +921,8 @@ void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, uint16_t local_cid, BT_HDR* p_buf
/* If only doing one write, break out */
log::debug("single_write is true, skipping");
break;
- }
- /* If nothing on the link queue, check the channel queue */
- else {
+ } else {
+ /* If nothing on the link queue, check the channel queue */
tL2C_TX_COMPLETE_CB_INFO cbi = {};
log::debug("Check next buffer");
p_buf = l2cu_get_next_buffer_to_send(p_lcb, &cbi);
diff --git a/system/stack/rfcomm/port_rfc.cc b/system/stack/rfcomm/port_rfc.cc
index 387e7a7197..be15fb1217 100644
--- a/system/stack/rfcomm/port_rfc.cc
+++ b/system/stack/rfcomm/port_rfc.cc
@@ -953,9 +953,8 @@ uint32_t port_rfc_send_tx_data(tPORT* p_port) {
events |= PORT_EV_TXEMPTY;
break;
}
- }
- /* queue is empty-- all data sent */
- else {
+ } else {
+ /* queue is empty-- all data sent */
mutex_global_unlock();
events |= PORT_EV_TXEMPTY;
diff --git a/system/stack/rfcomm/port_utils.cc b/system/stack/rfcomm/port_utils.cc
index 7f64661ead..88276d0d26 100644
--- a/system/stack/rfcomm/port_utils.cc
+++ b/system/stack/rfcomm/port_utils.cc
@@ -480,21 +480,18 @@ void port_flow_control_peer(tPORT* p_port, bool enable, uint16_t count) {
p_port->rx.peer_fc = false;
}
- }
- /* else want to disable flow from peer */
- else {
+ } else {
+ /* else want to disable flow from peer */
/* if client registered data callback, just do what they want */
if (p_port->p_data_callback || p_port->p_data_co_callback) {
p_port->rx.peer_fc = true;
- }
- /* if queue count reached credit rx max, set peer fc */
- else if (fixed_queue_length(p_port->rx.queue) >= p_port->credit_rx_max) {
+ } else if (fixed_queue_length(p_port->rx.queue) >= p_port->credit_rx_max) {
+ /* if queue count reached credit rx max, set peer fc */
p_port->rx.peer_fc = true;
}
}
- }
- /* else using TS 07.10 flow control */
- else {
+ } else {
+ /* else using TS 07.10 flow control */
/* if want to enable flow from peer */
if (enable) {
/* If rfcomm suspended traffic from the peer based on the rx_queue_size */
@@ -508,19 +505,17 @@ void port_flow_control_peer(tPORT* p_port, bool enable, uint16_t count) {
RFCOMM_FlowReq(p_port->rfc.p_mcb, p_port->dlci, true);
}
}
- }
- /* else want to disable flow from peer */
- else {
+ } else {
+ /* else want to disable flow from peer */
/* if client registered data callback, just do what they want */
if (p_port->p_data_callback || p_port->p_data_co_callback) {
p_port->rx.peer_fc = true;
RFCOMM_FlowReq(p_port->rfc.p_mcb, p_port->dlci, false);
- }
- /* Check the size of the rx queue. If it exceeds certain */
- /* level and flow control has not been sent to the peer do it now */
- else if (((p_port->rx.queue_size > PORT_RX_HIGH_WM) ||
- (fixed_queue_length(p_port->rx.queue) > PORT_RX_BUF_HIGH_WM)) &&
- !p_port->rx.peer_fc) {
+ } else if (((p_port->rx.queue_size > PORT_RX_HIGH_WM) ||
+ (fixed_queue_length(p_port->rx.queue) > PORT_RX_BUF_HIGH_WM)) &&
+ !p_port->rx.peer_fc) {
+ /* Check the size of the rx queue. If it exceeds certain */
+ /* level and flow control has not been sent to the peer do it now */
log::verbose("PORT_DataInd Data reached HW. Sending FC set.");
p_port->rx.peer_fc = true;
diff --git a/system/stack/smp/smp_act.cc b/system/stack/smp/smp_act.cc
index 6de1db3ae8..8ad85378a3 100644
--- a/system/stack/smp/smp_act.cc
+++ b/system/stack/smp/smp_act.cc
@@ -1296,11 +1296,10 @@ void smp_check_auth_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
/* if failed for encryption after pairing, send callback */
if (p_cb->flags & SMP_PAIR_FLAG_ENC_AFTER_PAIR) {
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
- }
- /* if enc failed for old security information */
- /* if central device, clean up and abck to idle; peripheral device do
- * nothing */
- else if (p_cb->role == HCI_ROLE_CENTRAL) {
+ } else if (p_cb->role == HCI_ROLE_CENTRAL) {
+ /* if enc failed for old security information */
+ /* if central device, clean up and abck to idle; peripheral device do
+ * nothing */
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
}
}