OSDN Git Service

[system][bt] fix -Wreorder-init-list
authorNick Desaulniers <ndesaulniers@google.com>
Wed, 9 Oct 2019 18:06:55 +0000 (11:06 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Thu, 10 Oct 2019 21:02:57 +0000 (14:02 -0700)
C++20 will require members in a designated initializer to be in order
unlike C99.

Bug: 139945549
Test: mm
Change-Id: I62dd309d5749c74c18e4291e7d1cef1f3587bf41
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
13 files changed:
audio_hal_interface/client_interface.h
bta/gatt/bta_gattc_queue.cc
bta/gatt/database.cc
bta/gatt/database_builder.cc
bta/jv/bta_jv_act.cc
btif/src/btif_rc.cc
service/gatt_server.cc
service/gatt_server_old.cc
service/test/gatt_server_unittest.cc
stack/gap/gap_ble.cc
stack/gatt/gatt_attr.cc
stack/l2cap/l2cap_client.cc
test/suite/gatt/gatt_unittest.cc

index 11984aa..8ee2bb1 100644 (file)
@@ -158,8 +158,9 @@ class BluetoothAudioClientInterface {
 
   static constexpr PcmParameters kInvalidPcmConfiguration = {
       .sampleRate = SampleRate::RATE_UNKNOWN,
+      .channelMode = ChannelMode::UNKNOWN,
       .bitsPerSample = BitsPerSample::BITS_UNKNOWN,
-      .channelMode = ChannelMode::UNKNOWN};
+  };
 
  private:
   // Helper function to connect to an IBluetoothAudioProvider
index 6d9fff3..6d8f57c 100644 (file)
@@ -171,9 +171,9 @@ void BtaGattQueue::WriteCharacteristic(uint16_t conn_id, uint16_t handle,
                                        GATT_WRITE_OP_CB cb, void* cb_data) {
   gatt_op_queue[conn_id].push_back({.type = GATT_WRITE_CHAR,
                                     .handle = handle,
-                                    .write_type = write_type,
                                     .write_cb = cb,
                                     .write_cb_data = cb_data,
+                                    .write_type = write_type,
                                     .value = std::move(value)});
   gatt_execute_next_op(conn_id);
 }
@@ -184,9 +184,9 @@ void BtaGattQueue::WriteDescriptor(uint16_t conn_id, uint16_t handle,
                                    GATT_WRITE_OP_CB cb, void* cb_data) {
   gatt_op_queue[conn_id].push_back({.type = GATT_WRITE_DESC,
                                     .handle = handle,
-                                    .write_type = write_type,
                                     .write_cb = cb,
                                     .write_cb_data = cb_data,
+                                    .write_type = write_type,
                                     .value = std::move(value)});
   gatt_execute_next_op(conn_id);
 }
index 1486b08..58f7056 100644 (file)
@@ -127,11 +127,12 @@ Database Database::Deserialize(const std::vector<StoredAttribute>& nv_attr,
   for (; it != nv_attr.cend(); ++it) {
     const auto& attr = *it;
     if (attr.type != PRIMARY_SERVICE && attr.type != SECONDARY_SERVICE) break;
-    result.services.emplace_back(
-        Service{.handle = attr.handle,
-                .end_handle = attr.value.service.end_handle,
-                .is_primary = (attr.type == PRIMARY_SERVICE),
-                .uuid = attr.value.service.uuid});
+    result.services.emplace_back(Service{
+        .handle = attr.handle,
+        .uuid = attr.value.service.uuid,
+        .is_primary = (attr.type == PRIMARY_SERVICE),
+        .end_handle = attr.value.service.end_handle,
+    });
   }
 
   auto current_service_it = result.services.begin();
@@ -168,11 +169,12 @@ Database Database::Deserialize(const std::vector<StoredAttribute>& nv_attr,
           .end_handle = attr.value.included_service.end_handle,
       });
     } else if (attr.type == CHARACTERISTIC) {
-      current_service_it->characteristics.emplace_back(
-          Characteristic{.declaration_handle = attr.handle,
-                         .value_handle = attr.value.characteristic.value_handle,
-                         .properties = attr.value.characteristic.properties,
-                         .uuid = attr.value.characteristic.uuid});
+      current_service_it->characteristics.emplace_back(Characteristic{
+          .declaration_handle = attr.handle,
+          .uuid = attr.value.characteristic.uuid,
+          .value_handle = attr.value.characteristic.value_handle,
+          .properties = attr.value.characteristic.properties,
+      });
 
     } else {
       current_service_it->characteristics.back().descriptors.emplace_back(
index ed065ab..98c0a27 100644 (file)
@@ -32,10 +32,12 @@ void DatabaseBuilder::AddService(uint16_t handle, uint16_t end_handle,
   // general case optimization - we add services in order
   if (database.services.empty() ||
       database.services.back().end_handle < handle) {
-    database.services.emplace_back(Service{.handle = handle,
-                                           .end_handle = end_handle,
-                                           .is_primary = is_primary,
-                                           .uuid = uuid});
+    database.services.emplace_back(Service{
+        .handle = handle,
+        .uuid = uuid,
+        .is_primary = is_primary,
+        .end_handle = end_handle,
+    });
   } else {
     auto& vec = database.services;
 
@@ -45,10 +47,12 @@ void DatabaseBuilder::AddService(uint16_t handle, uint16_t end_handle,
         [](Service s, uint16_t handle) { return s.end_handle < handle; });
 
     // Insert new service just before it
-    vec.emplace(it, Service{.handle = handle,
-                            .end_handle = end_handle,
-                            .is_primary = is_primary,
-                            .uuid = uuid});
+    vec.emplace(it, Service{
+                        .handle = handle,
+                        .uuid = uuid,
+                        .is_primary = is_primary,
+                        .end_handle = end_handle,
+                    });
   }
 
   services_to_discover.insert({handle, end_handle});
@@ -90,11 +94,12 @@ void DatabaseBuilder::AddCharacteristic(uint16_t handle, uint16_t value_handle,
                  << loghex(value_handle) << " is after service end_handle="
                  << loghex(service->end_handle);
 
-  service->characteristics.emplace_back(
-      Characteristic{.declaration_handle = handle,
-                     .value_handle = value_handle,
-                     .properties = properties,
-                     .uuid = uuid});
+  service->characteristics.emplace_back(Characteristic{
+      .declaration_handle = handle,
+      .uuid = uuid,
+      .value_handle = value_handle,
+      .properties = properties,
+  });
   return;
 }
 
index 462ee9d..5cd8041 100644 (file)
@@ -1885,16 +1885,16 @@ static struct fc_channel* fcchan_get(uint16_t chan, char create) {
   static tL2CAP_FIXED_CHNL_REG fcr = {
       .pL2CA_FixedConn_Cb = fcchan_conn_chng_cbk,
       .pL2CA_FixedData_Cb = fcchan_data_cbk,
-      .default_idle_tout = 0xffff,
       .fixed_chnl_opts =
           {
               .mode = L2CAP_FCR_BASIC_MODE,
+              .tx_win_sz = 1,
               .max_transmit = 0xFF,
               .rtrans_tout = 2000,
               .mon_tout = 12000,
               .mps = 670,
-              .tx_win_sz = 1,
           },
+      .default_idle_tout = 0xffff,
   };
 
   while (t && t->chan != chan) t = t->next;
index 6935651..2b2bb22 100644 (file)
@@ -2535,9 +2535,9 @@ static bt_status_t set_volume(uint8_t volume) {
     BTIF_TRACE_DEBUG("%s: Peer supports absolute volume. newVolume: %d",
                      __func__, volume);
 
-    tAVRC_COMMAND avrc_cmd = {.volume = {.opcode = AVRC_OP_VENDOR,
-                                         .pdu = AVRC_PDU_SET_ABSOLUTE_VOLUME,
+    tAVRC_COMMAND avrc_cmd = {.volume = {.pdu = AVRC_PDU_SET_ABSOLUTE_VOLUME,
                                          .status = AVRC_STS_NO_ERROR,
+                                         .opcode = AVRC_OP_VENDOR,
                                          .volume = volume}};
 
     BT_HDR* p_msg = NULL;
index 52fd1ed..08c4f83 100644 (file)
@@ -68,18 +68,20 @@ bool GattServer::AddService(const bluetooth::Service& service,
 
   std::vector<btgatt_db_element_t> svc;
 
-  svc.push_back({.type = (service.primary() ? BTGATT_DB_PRIMARY_SERVICE
-                                            : BTGATT_DB_SECONDARY_SERVICE),
-                 .uuid = service.uuid()});
+  svc.push_back({
+      .uuid = service.uuid(),
+      .type = (service.primary() ? BTGATT_DB_PRIMARY_SERVICE
+                                 : BTGATT_DB_SECONDARY_SERVICE),
+  });
 
   for (const auto& characteristic : service.characteristics()) {
-    svc.push_back({.type = BTGATT_DB_CHARACTERISTIC,
-                   .uuid = characteristic.uuid(),
+    svc.push_back({.uuid = characteristic.uuid(),
+                   .type = BTGATT_DB_CHARACTERISTIC,
                    .properties = characteristic.properties(),
                    .permissions = characteristic.permissions()});
     for (const auto& descriptor : characteristic.descriptors())
-      svc.push_back({.type = BTGATT_DB_DESCRIPTOR,
-                     .uuid = descriptor.uuid(),
+      svc.push_back({.uuid = descriptor.uuid(),
+                     .type = BTGATT_DB_DESCRIPTOR,
                      .permissions = descriptor.permissions()});
   }
 
index b583d93..cfc394c 100644 (file)
@@ -136,8 +136,10 @@ void RegisterServerCallback(int status, int server_if,
 
   g_internal->server_if = server_if;
 
-  pending_svc_decl.push_back(
-      {.type = BTGATT_DB_PRIMARY_SERVICE, .uuid = app_uuid});
+  pending_svc_decl.push_back({
+      .uuid = app_uuid,
+      .type = BTGATT_DB_PRIMARY_SERVICE,
+  });
 }
 
 void ServiceAddedCallback(int status, int server_if,
@@ -502,8 +504,8 @@ int ServerInternals::Initialize() {
 bt_status_t ServerInternals::AddCharacteristic(const Uuid& uuid,
                                                uint8_t properties,
                                                uint16_t permissions) {
-  pending_svc_decl.push_back({.type = BTGATT_DB_CHARACTERISTIC,
-                              .uuid = uuid,
+  pending_svc_decl.push_back({.uuid = uuid,
+                              .type = BTGATT_DB_CHARACTERISTIC,
                               .properties = properties,
                               .permissions = permissions});
   return BT_STATUS_SUCCESS;
index 7d7fec2..e19742d 100644 (file)
@@ -267,14 +267,14 @@ class GattServerPostRegisterTest : public GattServerTest {
     desc_handle_ = 0x0004;
 
     std::vector<btgatt_db_element_t> service_with_handles = {
-        {.type = BTGATT_DB_PRIMARY_SERVICE,
-         .uuid = uuid0,
+        {.uuid = uuid0,
+         .type = BTGATT_DB_PRIMARY_SERVICE,
          .attribute_handle = srvc_handle_},
-        {.type = BTGATT_DB_CHARACTERISTIC,
-         .uuid = uuid1,
+        {.uuid = uuid1,
+         .type = BTGATT_DB_CHARACTERISTIC,
          .attribute_handle = char_handle_},
-        {.type = BTGATT_DB_DESCRIPTOR,
-         .uuid = uuid2,
+        {.uuid = uuid2,
+         .type = BTGATT_DB_DESCRIPTOR,
          .attribute_handle = desc_handle_},
     };
 
index cce62d4..e71238f 100644 (file)
@@ -411,23 +411,26 @@ void gap_attr_db_init(void) {
   Uuid addr_res_uuid = Uuid::From16Bit(GATT_UUID_GAP_CENTRAL_ADDR_RESOL);
 
   btgatt_db_element_t service[] = {
-    {.type = BTGATT_DB_PRIMARY_SERVICE, .uuid = svc_uuid},
-    {.type = BTGATT_DB_CHARACTERISTIC,
-     .uuid = name_uuid,
+    {
+        .uuid = svc_uuid,
+        .type = BTGATT_DB_PRIMARY_SERVICE,
+    },
+    {.uuid = name_uuid,
+     .type = BTGATT_DB_CHARACTERISTIC,
      .properties = GATT_CHAR_PROP_BIT_READ,
      .permissions = GATT_PERM_READ},
-    {.type = BTGATT_DB_CHARACTERISTIC,
-     .uuid = icon_uuid,
+    {.uuid = icon_uuid,
+     .type = BTGATT_DB_CHARACTERISTIC,
      .properties = GATT_CHAR_PROP_BIT_READ,
      .permissions = GATT_PERM_READ},
-    {.type = BTGATT_DB_CHARACTERISTIC,
-     .uuid = addr_res_uuid,
+    {.uuid = addr_res_uuid,
+     .type = BTGATT_DB_CHARACTERISTIC,
      .properties = GATT_CHAR_PROP_BIT_READ,
      .permissions = GATT_PERM_READ}
 #if (BTM_PERIPHERAL_ENABLED == TRUE) /* Only needed for peripheral testing */
     ,
-    {.type = BTGATT_DB_CHARACTERISTIC,
-     .uuid = Uuid::From16Bit(GATT_UUID_GAP_PREF_CONN_PARAM),
+    {.uuid = Uuid::From16Bit(GATT_UUID_GAP_PREF_CONN_PARAM),
+     .type = BTGATT_DB_CHARACTERISTIC,
      .properties = GATT_CHAR_PROP_BIT_READ,
      .permissions = GATT_PERM_READ}
 #endif
index 8861a7a..1acfd81 100644 (file)
@@ -285,11 +285,16 @@ void gatt_profile_db_init(void) {
   Uuid char_uuid = Uuid::From16Bit(GATT_UUID_GATT_SRV_CHGD);
 
   btgatt_db_element_t service[] = {
-      {.type = BTGATT_DB_PRIMARY_SERVICE, .uuid = service_uuid},
-      {.type = BTGATT_DB_CHARACTERISTIC,
-       .uuid = char_uuid,
-       .properties = GATT_CHAR_PROP_BIT_INDICATE,
-       .permissions = 0}};
+      {
+          .uuid = service_uuid,
+          .type = BTGATT_DB_PRIMARY_SERVICE,
+      },
+      {
+          .uuid = char_uuid,
+          .type = BTGATT_DB_CHARACTERISTIC,
+          .properties = GATT_CHAR_PROP_BIT_INDICATE,
+          .permissions = 0,
+      }};
 
   GATTS_AddService(gatt_cb.gatt_if, service,
                    sizeof(service) / sizeof(btgatt_db_element_t));
index 76e4138..b3f3737 100644 (file)
@@ -70,8 +70,8 @@ static const tL2CAP_APPL_INFO l2cap_callbacks = {
     .pL2CA_ConfigCfm_Cb = config_completed_cb,
     .pL2CA_DisconnectInd_Cb = disconnect_request_cb,
     .pL2CA_DisconnectCfm_Cb = disconnect_completed_cb,
-    .pL2CA_CongestionStatus_Cb = congestion_cb,
     .pL2CA_DataInd_Cb = read_ready_cb,
+    .pL2CA_CongestionStatus_Cb = congestion_cb,
     .pL2CA_TxComplete_Cb = write_completed_cb,
 };
 
index 26fd850..b02c96a 100644 (file)
@@ -69,12 +69,21 @@ TEST_F(GattTest, GattServerBuild) {
   int server_if = server_interface_id();
 
   std::vector<btgatt_db_element_t> service = {
-      {.type = BTGATT_DB_PRIMARY_SERVICE, .uuid = srvc_uuid},
-      {.type = BTGATT_DB_CHARACTERISTIC,
-       .uuid = char_uuid,
-       .properties = 0x10 /* notification */,
-       .permissions = 0x01 /* read only */},
-      {.type = BTGATT_DB_DESCRIPTOR, .uuid = desc_uuid, .permissions = 0x01}};
+      {
+          .uuid = srvc_uuid,
+          .type = BTGATT_DB_PRIMARY_SERVICE,
+      },
+      {
+          .uuid = char_uuid,
+          .type = BTGATT_DB_CHARACTERISTIC,
+          .properties = 0x10,  /* notification */
+          .permissions = 0x01, /* read only */
+      },
+      {
+          .uuid = desc_uuid,
+          .type = BTGATT_DB_DESCRIPTOR,
+          .permissions = 0x01,
+      }};
 
   gatt_server_interface()->add_service(server_if, service);
   semaphore_wait(service_added_callback_sem_);