Skip to content

Commit

Permalink
add explicit fallthrough to switch statement
Browse files Browse the repository at this point in the history
Change-Id: I5ce9b3fb3eab1accdae0e7aaed7e6c0b2edd4cdb
(cherry picked from commit 3af636adfc67492d103e227cd3119957d5e18d81)
  • Loading branch information
Scott Lobdell authored and Gerrit - the friendly Code Review server committed Dec 28, 2018
1 parent 8b5ba7a commit fc995a1
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 26 deletions.
4 changes: 4 additions & 0 deletions bta/ag/bta_ag_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,13 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
switch (cmd) {
case BTA_AG_AT_A_EVT:
alarm_cancel(p_scb->ring_timer);
FALLTHROUGH;
case BTA_AG_SPK_EVT:
FALLTHROUGH;
case BTA_AG_MIC_EVT:
FALLTHROUGH;
case BTA_AG_AT_CHUP_EVT:
FALLTHROUGH;
case BTA_AG_AT_CBC_EVT:
/* send OK */
bta_ag_send_ok(p_scb);
Expand Down
2 changes: 1 addition & 1 deletion bta/dm/bta_dm_act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2817,7 +2817,7 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) {
sec_event.cfm_req.loc_io_caps = p_data->cfm_req.loc_io_caps;
sec_event.cfm_req.rmt_io_caps = p_data->cfm_req.rmt_io_caps;

/* continue to next case */
FALLTHROUGH;
/* Passkey entry mode, mobile device with output capability is very
unlikely to receive key request, so skip this event */
/*case BTM_SP_KEY_REQ_EVT: */
Expand Down
1 change: 1 addition & 0 deletions bta/hd/bta_hd_act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static bool check_descriptor(uint8_t* data, uint16_t length,

case 0x85: // Report ID
*has_report_id = TRUE;
FALLTHROUGH;

default:
ptr += (item & 0x03);
Expand Down
5 changes: 4 additions & 1 deletion bta/hh/bta_hh_act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,9 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
/* GET_ transsaction, handshake indicate unsupported request */
case BTA_HH_GET_PROTO_EVT:
hs_data.rsp_data.proto_mode = BTA_HH_PROTO_UNKNOWN;
/* fall through */
FALLTHROUGH;
case BTA_HH_GET_RPT_EVT:
FALLTHROUGH;
case BTA_HH_GET_IDLE_EVT:
hs_data.handle = p_cb->hid_handle;
/* if handshake gives an OK code for these transaction, fill in UNSUPT */
Expand All @@ -656,7 +657,9 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {

/* acknoledgement from HID device for SET_ transaction */
case BTA_HH_SET_RPT_EVT:
FALLTHROUGH;
case BTA_HH_SET_PROTO_EVT:
FALLTHROUGH;
case BTA_HH_SET_IDLE_EVT:
cback_data.handle = p_cb->hid_handle;
cback_data.status = bta_hh_get_trans_status(p_data->hid_cback.data);
Expand Down
5 changes: 4 additions & 1 deletion bta/hh/bta_hh_le.cc
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,11 @@ static void write_rpt_ctl_cfg_cb(uint16_t conn_id, tGATT_STATUS status,
case GATT_UUID_BATTERY_LEVEL: /* battery level clt cfg registered */
hid_inst_id = bta_hh_le_find_service_inst_by_battery_inst_id(
p_dev_cb, srvc_inst_id);
/* FALLTHROUGH */
FALLTHROUGH;
case GATT_UUID_HID_BT_KB_INPUT:
FALLTHROUGH;
case GATT_UUID_HID_BT_MOUSE_INPUT:
FALLTHROUGH;
case GATT_UUID_HID_REPORT:
if (status == BTA_GATT_OK)
p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].report[p_dev_cb->clt_cfg_idx].client_cfg_value =
Expand All @@ -919,6 +921,7 @@ static void write_rpt_ctl_cfg_cb(uint16_t conn_id, tGATT_STATUS status,

default:
APPL_TRACE_ERROR("Unknown char ID clt cfg: 0x%04x", char_uuid);
break;
}
}
/*******************************************************************************
Expand Down
1 change: 1 addition & 0 deletions btif/src/btif_av.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2662,6 +2662,7 @@ static void btif_av_handle_event(uint16_t event, char* p_param) {
btif_report_audio_state(BTAV_AUDIO_STATE_STARTED, &(btif_av_cb[index].peer_bda));
}
btif_av_cb[index].is_device_playing = true;
FALLTHROUGH;
case BTIF_AV_RESET_REMOTE_STARTED_FLAG_EVT:
btif_av_reset_remote_started_flag();
return;
Expand Down
12 changes: 11 additions & 1 deletion btif/src/btif_dm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
btif_dm_cb_create_bond(bd_addr, BTA_TRANSPORT_UNKNOWN);
return;
}
/* Fall-through */
FALLTHROUGH;
case HCI_ERR_CONNECTION_TOUT:
status = BT_STATUS_RMT_DEV_DOWN;
break;
Expand All @@ -1353,15 +1353,24 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
}

/* map the auth failure codes, so we can retry pairing if necessary */
FALLTHROUGH;
case HCI_ERR_AUTH_FAILURE:
btif_storage_remove_bonded_device(&bd_addr);
FALLTHROUGH;
case HCI_ERR_HOST_REJECT_SECURITY:
FALLTHROUGH;
case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
FALLTHROUGH;
case HCI_ERR_UNIT_KEY_USED:
FALLTHROUGH;
case HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED:
FALLTHROUGH;
case HCI_ERR_INSUFFCIENT_SECURITY:
FALLTHROUGH;
case HCI_ERR_PEER_USER:
FALLTHROUGH;
case HCI_ERR_UNSPECIFIED:
FALLTHROUGH;
case HCI_ERR_REPEATED_ATTEMPTS:
BTIF_TRACE_DEBUG(" %s() Authentication fail reason %d",
__FUNCTION__, p_auth_cmpl->fail_reason);
Expand All @@ -1380,6 +1389,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {

default:
status = BT_STATUS_FAIL;
break;
}
/* Special Handling for HID Devices */
if (check_cod(&bd_addr, COD_HID_POINTING)) {
Expand Down
1 change: 1 addition & 0 deletions btif/src/btif_hf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ static void btif_hf_upstreams_evt(uint16_t event, char* p_param) {
}
}
#endif
FALLTHROUGH;
case BTA_AG_MIC_EVT:
HAL_HF_CBACK(bt_hf_callbacks, VolumeControlCallback,
(event == BTA_AG_SPK_EVT) ? BTHF_VOLUME_TYPE_SPK
Expand Down
4 changes: 3 additions & 1 deletion btif/src/btif_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ bt_status_t btif_storage_get_adapter_property(bt_property_t* property) {
Uuid::From16Bit(UUID_SERVCLASS_AG_HANDSFREE);
num_uuids++;
}
FALLTHROUGH;
/* intentional fall through: Send both BFP & HSP UUIDs if HFP is
* enabled */
case BTA_HSP_SERVICE_ID: {
Expand Down Expand Up @@ -883,7 +884,7 @@ bt_status_t btif_storage_remove_bonded_device(
*******************************************************************************/
bt_status_t btif_storage_is_device_bonded(RawAddress *remote_bd_addr) {


char bdstr[18] = {'\0'};
snprintf(bdstr, sizeof(bdstr), "%02x:%02x:%02x:%02x:%02x:%02x",
remote_bd_addr->address[0],
Expand Down Expand Up @@ -1112,6 +1113,7 @@ bt_status_t btif_storage_get_ble_bonding_key(RawAddress* remote_bd_addr,
break;
case BTIF_DM_LE_KEY_LID:
name = "LE_KEY_LID";
break;
default:
return BT_STATUS_FAIL;
}
Expand Down
1 change: 1 addition & 0 deletions stack/a2dp/a2dp_codec_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ int A2DP_GetTrackBitsPerSample(const uint8_t* p_codec_info) {
return 32;
}
}
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions stack/a2dp/a2dp_vendor_ldac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ bool A2dpCodecConfigLdac::setCodecConfig(const uint8_t* p_peer_codec_info,
codec_capability_.sample_rate = codec_user_config_.sample_rate;
codec_config_.sample_rate = codec_user_config_.sample_rate;
}
break;
case BTAV_A2DP_CODEC_SAMPLE_RATE_NONE:
codec_capability_.sample_rate = BTAV_A2DP_CODEC_SAMPLE_RATE_NONE;
codec_config_.sample_rate = BTAV_A2DP_CODEC_SAMPLE_RATE_NONE;
Expand Down
2 changes: 1 addition & 1 deletion stack/avrc/avrc_bld_tg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ static BT_HDR* avrc_bld_init_rsp_buffer(tAVRC_RESPONSE* p_rsp) {
case AVRC_OP_VENDOR:
/* reserved 0, packet_type 0 */
UINT8_TO_BE_STREAM(p_data, 0);
/* continue to the next "case to add length */
FALLTHROUGH;

case AVRC_OP_BROWSE:
/* add fixed lenth - 0 */
Expand Down
10 changes: 8 additions & 2 deletions stack/btm/btm_ble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1604,9 +1604,11 @@ tBTM_STATUS btm_ble_set_encryption(const RawAddress& bd_addr,
cmd = btm_ble_start_encrypt(bd_addr, false, NULL);
break;
}
FALLTHROUGH;
/* if salve role then fall through to call SMP_Pair below which will send a
sec_request to request the master to encrypt the link */
case BTM_BLE_SEC_ENCRYPT_NO_MITM:
FALLTHROUGH;
case BTM_BLE_SEC_ENCRYPT_MITM:
auth_req = (sec_act == BTM_BLE_SEC_ENCRYPT_NO_MITM)
? SMP_AUTH_GEN_BOND
Expand Down Expand Up @@ -2104,12 +2106,16 @@ uint8_t btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,
break;

case SMP_PASSKEY_REQ_EVT:
FALLTHROUGH;
case SMP_PASSKEY_NOTIF_EVT:
FALLTHROUGH;
case SMP_OOB_REQ_EVT:
FALLTHROUGH;
case SMP_NC_REQ_EVT:
FALLTHROUGH;
case SMP_SC_OOB_REQ_EVT:
/* fall through */
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
FALLTHROUGH;

case SMP_SEC_REQUEST_EVT:
if (event == SMP_SEC_REQUEST_EVT &&
Expand All @@ -2120,7 +2126,7 @@ uint8_t btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,
btm_cb.pairing_bda = bd_addr;
p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING;
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_LE_ACTIVE;
/* fall through */
FALLTHROUGH;

case SMP_COMPLT_EVT:
if (btm_cb.api.p_le_callback) {
Expand Down
2 changes: 1 addition & 1 deletion stack/btu/btu_hcif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
}
}
#endif
/* Case Falls Through */
FALLTHROUGH;

case HCI_HOLD_MODE:
case HCI_SNIFF_MODE:
Expand Down
10 changes: 7 additions & 3 deletions stack/gatt/att_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,11 @@ BT_HDR* attp_build_sr_msg(tGATT_TCB& tcb, uint8_t op_code,
offset = p_msg->attr_value.offset;
/* Coverity: [FALSE-POSITIVE error] intended fall through */
/* Missing break statement between cases in switch statement */
/* fall through */
FALLTHROUGH;
case GATT_RSP_READ_BY_TYPE:
FALLTHROUGH;
case GATT_RSP_READ:
FALLTHROUGH;
case GATT_HANDLE_VALUE_NOTIF:
case GATT_HANDLE_VALUE_IND:
return attp_build_value_cmd(
Expand Down Expand Up @@ -482,7 +484,7 @@ tGATT_STATUS attp_send_cl_msg(tGATT_TCB& tcb, tGATT_CLCB* p_clcb,

case GATT_REQ_READ_BLOB:
offset = p_msg->read_blob.offset;
/* fall through */
FALLTHROUGH;
case GATT_REQ_READ:
handle =
(op_code == GATT_REQ_READ) ? p_msg->handle : p_msg->read_blob.handle;
Expand All @@ -498,9 +500,11 @@ tGATT_STATUS attp_send_cl_msg(tGATT_TCB& tcb, tGATT_CLCB* p_clcb,

case GATT_REQ_PREPARE_WRITE:
offset = p_msg->attr_value.offset;
/* fall through */
FALLTHROUGH;
case GATT_REQ_WRITE:
FALLTHROUGH;
case GATT_CMD_WRITE:
FALLTHROUGH;
case GATT_SIGN_CMD_WRITE:
if (!GATT_HANDLE_IS_VALID(p_msg->attr_value.handle))
return GATT_ILLEGAL_PARAMETER;
Expand Down
8 changes: 6 additions & 2 deletions stack/gatt/gatt_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,18 +594,22 @@ tGATT_STATUS gatts_write_attr_perm_check(tGATT_SVC_DB* p_db, uint8_t op_code,
} else if (p_attr->uuid.Is16Bit()) {
switch (p_attr->uuid.As16Bit()) {
case GATT_UUID_CHAR_PRESENT_FORMAT: /* should be readable only */
FALLTHROUGH;
case GATT_UUID_CHAR_EXT_PROP: /* should be readable only */
FALLTHROUGH;
case GATT_UUID_CHAR_AGG_FORMAT: /* should be readable only */
FALLTHROUGH;
case GATT_UUID_CHAR_VALID_RANGE:
status = GATT_WRITE_NOT_PERMIT;
break;

case GATT_UUID_CHAR_CLIENT_CONFIG:
/* fall through */
FALLTHROUGH;
case GATT_UUID_CHAR_SRVR_CONFIG:
max_size = 2;
/* fall through */
FALLTHROUGH;
case GATT_UUID_CHAR_DESCRIPTION:
FALLTHROUGH;
default: /* any other must be character value declaration */
status = GATT_SUCCESS;
break;
Expand Down
5 changes: 3 additions & 2 deletions stack/gatt/gatt_sr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,15 @@ void gatts_process_write_req(tGATT_TCB& tcb, tGATT_SRV_LIST_ELEM& el,
sr_data.write_req.is_prep = true;
STREAM_TO_UINT16(sr_data.write_req.offset, p);
len -= 2;
/* fall through */
FALLTHROUGH;
case GATT_SIGN_CMD_WRITE:
if (op_code == GATT_SIGN_CMD_WRITE) {
VLOG(1) << "Write CMD with data sigining";
len -= GATT_AUTH_SIGN_LEN;
}
/* fall through */
FALLTHROUGH;
case GATT_CMD_WRITE:
FALLTHROUGH;
case GATT_REQ_WRITE:
if (op_code == GATT_REQ_WRITE || op_code == GATT_REQ_PREPARE_WRITE)
sr_data.write_req.need_rsp = true;
Expand Down
16 changes: 9 additions & 7 deletions stack/l2cap/l2c_fcr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,20 +2205,22 @@ bool l2c_fcr_renegotiate_chan(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) {
L2CAP_TRACE_DEBUG("l2c_fcr_renegotiate_chan(Trying ERTM)");
p_ccb->our_cfg.fcr.mode = L2CAP_FCR_ERTM_MODE;
can_renegotiate = true;
} else /* Falls through */
}
FALLTHROUGH;

case L2CAP_FCR_ERTM_MODE: {
case L2CAP_FCR_ERTM_MODE:
{
/* We can try basic for any other peer mode if we support it */
if (p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_BASIC) {
L2CAP_TRACE_DEBUG("l2c_fcr_renegotiate_chan(Trying Basic)");
can_renegotiate = true;
p_ccb->our_cfg.fcr.mode = L2CAP_FCR_BASIC_MODE;
}
} break;

default:
/* All other scenarios cannot be renegotiated */
break;
}
break;
default:
/* All other scenarios cannot be renegotiated */
break;
}

if (can_renegotiate) {
Expand Down
2 changes: 1 addition & 1 deletion stack/rfcomm/rfc_mx_fsm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void rfc_mx_sm_sabme_wait_ua(tRFC_MCB* p_mcb, uint16_t event,

case RFC_EVENT_DM:
rfc_timer_stop(p_mcb);
/* Case falls through */
FALLTHROUGH;

case RFC_MX_EVENT_CONF_IND: /* workaround: we don't support reconfig */
case RFC_MX_EVENT_CONF_CNF: /* workaround: we don't support reconfig */
Expand Down
2 changes: 1 addition & 1 deletion stack/rfcomm/rfc_port_fsm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void rfc_port_sm_disc_wait_ua(tPORT* p_port, uint16_t event, void* p_data) {

case RFC_EVENT_UA:
p_port->rfc.p_mcb->is_disc_initiator = true;
/* Case falls through */
FALLTHROUGH;

case RFC_EVENT_DM:
RFCOMM_TRACE_WARNING("%s, RFC_EVENT_DM|RFC_EVENT_UA[%d], index=%d",
Expand Down
2 changes: 1 addition & 1 deletion stack/sdp/sdp_discovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ static uint8_t* add_attr(uint8_t* p, tSDP_DISCOVERY_DB* p_db,
break;
}
}
/* Case falls through */
FALLTHROUGH;

case TWO_COMP_INT_DESC_TYPE:
switch (attr_len) {
Expand Down

0 comments on commit fc995a1

Please sign in to comment.