OSDN Git Service

[system][bt] address -Wimplicit-fallthrough
authorNick Desaulniers <ndesaulniers@google.com>
Fri, 1 Nov 2019 16:05:35 +0000 (09:05 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Mon, 4 Nov 2019 22:24:46 +0000 (14:24 -0800)
The compiler upgrade in b/139945549 can now check C code for
-Wimplicit-fallthrough. In b/143713277, were moving the cflags for
projects that disable this warning to cppflags. For this subsystem, just
address the warnings and remove disabling it.

These cases should be carefully reviewed; modifications that weren't
additions of fallthrough attributes were likely existing bugs.

Bug: 139945549
Bug: 143713277
Test: mm
Change-Id: Icafeed1d18991e83f42e5efd13e8ab8d15068d79
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
14 files changed:
bta/Android.bp
bta/dm/bta_dm_act.cc
bta/hd/bta_hd_act.cc
bta/hf_client/bta_hf_client_sco.cc
btif/Android.bp
btif/src/btif_dm.cc
btif/src/btif_storage.cc
gd/Android.bp
gd/l2cap/classic/cert/cert.cc
gd/l2cap/classic/internal/signalling_manager.cc
gd/packet/parser/Android.bp
stack/Android.bp
stack/avrc/avrc_bld_tg.cc
stack/l2cap/l2c_fcr.cc

index 0e7bfe8..824076e 100644 (file)
@@ -34,7 +34,6 @@ cc_defaults {
 cc_library_static {
     name: "libbt-bta",
     defaults: ["fluoride_bta_defaults"],
-    cflags: ["-Wno-implicit-fallthrough"],
     srcs: [
         "ag/bta_ag_act.cc",
         "ag/bta_ag_api.cc",
index 5b9b71c..43befc2 100644 (file)
@@ -2507,7 +2507,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: */
index 0d677ee..a37a051 100644 (file)
@@ -62,7 +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);
         break;
index 50820bd..faf970d 100644 (file)
@@ -305,6 +305,8 @@ static void bta_hf_client_sco_event(tBTA_HF_CLIENT_CB* client_cb,
         case BTA_HF_CLIENT_SCO_LISTEN_E:
           /* create SCO listen connection */
           bta_hf_client_sco_create(client_cb, false);
+          /* TODO(b/143901894): Is this correct? */
+          [[fallthrough]];
 
         case BTA_HF_CLIENT_SCO_OPEN_E:
           /* remove listening connection */
index 98b61a3..6be1d81 100644 (file)
@@ -122,7 +122,6 @@ cc_library_static {
     ],
     cflags: [
         "-DBUILDCFG",
-        "-Wno-implicit-fallthrough",
     ],
 
 }
index 67a059e..c6a8a63 100644 (file)
@@ -1188,6 +1188,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
       case HCI_ERR_AUTH_FAILURE:
       case HCI_ERR_KEY_MISSING:
         btif_storage_remove_bonded_device(&bd_addr);
+        [[fallthrough]];
       case HCI_ERR_HOST_REJECT_SECURITY:
       case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
       case HCI_ERR_UNIT_KEY_USED:
index 2427493..e203d2f 100644 (file)
@@ -1119,6 +1119,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;
   }
index 61bb5a7..fc6461b 100644 (file)
@@ -28,7 +28,6 @@ cc_defaults {
         "-DLOG_NDEBUG=1",
         "-DGOOGLE_PROTOBUF_NO_RTTI",
         "-Wno-unused-parameter",
-        "-Wno-implicit-fallthrough",
         "-Wno-unused-result",
     ],
     conlyflags: [
index c1ce493..26c41ef 100644 (file)
@@ -271,6 +271,7 @@ class L2capModuleCertService : public L2capModuleCert::Service {
             break;
           }
         }
+        break;
       }
       default:
         return;
index 2608dbc..8475bcc 100644 (file)
@@ -378,6 +378,7 @@ void ClassicSignallingManager::on_incoming_packet() {
       OnConfigurationResponse(configuration_response_view.GetIdentifier(), configuration_response_view.GetSourceCid(),
                               configuration_response_view.GetContinuation(), configuration_response_view.GetResult(),
                               configuration_response_view.GetConfig());
+      return;
     }
     case CommandCode::DISCONNECTION_REQUEST: {
       DisconnectionRequestView disconnection_request_view = DisconnectionRequestView::Create(control_packet_view);
index ebd3d17..97f323a 100644 (file)
@@ -38,7 +38,6 @@ cc_binary_host {
         "libc++fs",
     ],
     cppflags: [
-        "-Wno-implicit-fallthrough",
         "-fno-exceptions",
         "-O0",
     ],
index 7a08c4f..825459b 100644 (file)
@@ -46,7 +46,6 @@ cc_library_static {
         "system/bt/bta/sys",
         "system/bt/utils/include",
     ],
-    cflags: ["-Wno-implicit-fallthrough"],
     srcs: crypto_toolbox_srcs + [
         "a2dp/a2dp_aac.cc",
         "a2dp/a2dp_aac_decoder.cc",
index b28c9e2..1dac160 100644 (file)
@@ -1338,8 +1338,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 */
       UINT16_TO_BE_STREAM(p_data, 0);
index 857a0bf..920448b 100644 (file)
@@ -2163,23 +2163,29 @@ bool l2c_fcr_renegotiate_chan(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) {
           /* Peer wants ERTM and we support it */
           if ((peer_mode == L2CAP_FCR_ERTM_MODE) &&
               (p_ccb->ertm_info.allowed_modes & L2CAP_FCR_CHAN_OPT_ERTM)) {
-            L2CAP_TRACE_DEBUG("l2c_fcr_renegotiate_chan(Trying ERTM)");
+            L2CAP_TRACE_DEBUG("%s(Trying ERTM)", __func__);
             p_ccb->our_cfg.fcr.mode = L2CAP_FCR_ERTM_MODE;
             can_renegotiate = true;
-          } else /* Falls through */
-
-          case L2CAP_FCR_ERTM_MODE: {
+          } else if (p_ccb->ertm_info.allowed_modes &
+                     L2CAP_FCR_CHAN_OPT_BASIC) {
             /* 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;
+            L2CAP_TRACE_DEBUG("%s(Trying Basic)", __func__);
+            can_renegotiate = true;
+            p_ccb->our_cfg.fcr.mode = L2CAP_FCR_BASIC_MODE;
+          }
+          break;
+        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("%s(Trying Basic)", __func__);
+            can_renegotiate = true;
+            p_ccb->our_cfg.fcr.mode = L2CAP_FCR_BASIC_MODE;
+          }
+          break;
 
-          default:
-            /* All other scenarios cannot be renegotiated */
-            break;
+        default:
+          /* All other scenarios cannot be renegotiated */
+          break;
       }
 
       if (can_renegotiate) {