OSDN Git Service

Fix clang-tidy warnings in bt.
authorChih-Hung Hsieh <chh@google.com>
Wed, 17 Aug 2016 21:12:51 +0000 (14:12 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 18 Aug 2016 00:29:13 +0000 (00:29 +0000)
* Add explicit keyword to conversion constructors,
  or add NOLINT to implicit conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters,
  or add NOLINT to keep same callback function signature.
Bug: 30407689
* Use const reference type for loop index variables to avoid unnecessary copy.
Bug: 30413223
* Use const reference type to avoid unnecessary copy.
Bug: 30413862
Test: build with WITH_TIDY=1

Change-Id: I8237d332f32d7be09ab72a8de82160fdb776dcd1

27 files changed:
service/client/main.cc
service/common/android/bluetooth/bluetooth_gatt_characteristic.h
service/common/android/bluetooth/bluetooth_gatt_descriptor.h
service/common/android/bluetooth/bluetooth_gatt_included_service.h
service/common/android/bluetooth/bluetooth_gatt_service.h
service/common/bluetooth/scan_result.cc
service/common/bluetooth/scan_result.h
service/gatt_server.cc
service/gatt_server_old.cc
service/hal/bluetooth_gatt_interface.cc
service/hal/bluetooth_gatt_interface.h
service/hal/fake_bluetooth_gatt_interface.cc
service/hal/fake_bluetooth_gatt_interface.h
service/ipc/binder/bluetooth_binder_server.cc
service/ipc/binder/bluetooth_low_energy_binder_server.cc
service/low_energy_client.cc
service/low_energy_client.h
service/test/low_energy_client_unittest.cc
vendor_libs/test_vendor_lib/include/dual_mode_controller.h
vendor_libs/test_vendor_lib/include/event_packet.h
vendor_libs/test_vendor_lib/include/hci_transport.h
vendor_libs/test_vendor_lib/include/test_channel_transport.h
vendor_libs/test_vendor_lib/src/async_manager.cc
vendor_libs/test_vendor_lib/src/dual_mode_controller.cc
vendor_libs/test_vendor_lib/src/event_packet.cc
vendor_libs/test_vendor_lib/src/hci_transport.cc
vendor_libs/test_vendor_lib/src/test_channel_transport.cc

index 103bb47..d85e2b6 100644 (file)
@@ -700,7 +700,7 @@ void HandleStartLeScan(IBluetooth* bt_iface, const vector<string>& args) {
     return;
   }
 
-  for (auto arg : args) {
+  for (const auto& arg : args) {
     if (arg == "-d") {
       dump_scan_record = true;
     } else if (arg == "-h") {
@@ -799,7 +799,7 @@ void HandleHelp(IBluetooth* /* bt_iface */, const vector<string>& /* args */) {
 const char kExecuteLong[] = "exec";
 const char kExecuteShort[] = "e";
 
-bool ExecuteCommand(sp<IBluetooth> bt_iface, std::string &command) {
+bool ExecuteCommand(const sp<IBluetooth>& bt_iface, std::string &command) {
   vector<string> args =
       base::SplitString(command, " ", base::TRIM_WHITESPACE,
                         base::SPLIT_WANT_ALL);
index 95300a7..2286068 100644 (file)
@@ -31,7 +31,7 @@ namespace bluetooth {
 class BluetoothGattCharacteristic : public Parcelable, public ::bluetooth::Characteristic {
  public:
   BluetoothGattCharacteristic() = default;
-  BluetoothGattCharacteristic(const ::bluetooth::Characteristic& characteristic)
+  BluetoothGattCharacteristic(const ::bluetooth::Characteristic& characteristic)  // NOLINT(implicit)
       : ::bluetooth::Characteristic(characteristic){};
   ~BluetoothGattCharacteristic() = default;
 
index 8f9385d..c791c24 100644 (file)
@@ -31,7 +31,7 @@ namespace bluetooth {
 class BluetoothGattDescriptor : public Parcelable, public ::bluetooth::Descriptor {
  public:
   BluetoothGattDescriptor() = default;
-  BluetoothGattDescriptor(const ::bluetooth::Descriptor& characteristic)
+  BluetoothGattDescriptor(const ::bluetooth::Descriptor& characteristic)  // NOLINT(implicit)
       : ::bluetooth::Descriptor(characteristic){};
   ~BluetoothGattDescriptor() = default;
 
index 2692020..7ff344f 100644 (file)
@@ -33,7 +33,7 @@ namespace bluetooth {
 class BluetoothGattIncludedService : public Parcelable {
  public:
   BluetoothGattIncludedService() = default;
-  BluetoothGattIncludedService(const ::bluetooth::Service& service)
+  BluetoothGattIncludedService(const ::bluetooth::Service& service)  // NOLINT(implicit)
     : handle_(service.handle()), uuid_(service.uuid()),
       primary_(service.primary()) {};
   ~BluetoothGattIncludedService() = default;
index f9d9392..eb6a30e 100644 (file)
@@ -32,8 +32,8 @@ namespace bluetooth {
 class BluetoothGattService : public Parcelable, public ::bluetooth::Service {
  public:
   BluetoothGattService() = default;
-  BluetoothGattService(const ::bluetooth::Service& service) : ::bluetooth::Service(service){};
-  BluetoothGattService(const BluetoothGattIncludedService& includedService)
+  BluetoothGattService(const ::bluetooth::Service& service) : ::bluetooth::Service(service){};  // NOLINT(implicit)
+  BluetoothGattService(const BluetoothGattIncludedService& includedService)  // NOLINT(implicit)
     : ::bluetooth::Service(includedService.handle(), includedService.primary(),
                            includedService.uuid(), {}, {}) {};
   ~BluetoothGattService() = default;
index 7656778..9e28e41 100644 (file)
@@ -24,7 +24,7 @@
 namespace bluetooth {
 
 ScanResult::ScanResult(const std::string& device_address,
-                       const std::vector<uint8_t> scan_record,
+                       const std::vector<uint8_t>& scan_record,
                        int rssi)
     : device_address_(device_address),
       scan_record_(scan_record),
index 3ba88f6..9be25b5 100644 (file)
@@ -28,7 +28,7 @@ namespace bluetooth {
 class ScanResult {
  public:
   ScanResult(const std::string& device_address,
-             const std::vector<uint8_t> scan_record,
+             const std::vector<uint8_t>& scan_record,
              int rssi);
   ScanResult() = default;
   ~ScanResult() = default;
index 9a76f66..57ac6ba 100644 (file)
@@ -147,7 +147,7 @@ bool GattServer::SendResponse(
   }
 
   std::shared_ptr<Connection> connection;
-  for (auto tmp : iter->second) {
+  for (const auto& tmp : iter->second) {
     if (tmp->request_id_to_handle.find(request_id) ==
         tmp->request_id_to_handle.end())
       continue;
@@ -218,7 +218,7 @@ bool GattServer::SendNotification(
 
   // Send the notification/indication on all matching connections.
   int send_count = 0;
-  for (auto conn : conn_iter->second) {
+  for (const auto& conn : conn_iter->second) {
     // Make sure that one isn't already pending for this connection.
     if (pending_indications_.find(conn->conn_id) !=
         pending_indications_.end()) {
index 9f196a8..dcc941c 100644 (file)
@@ -580,8 +580,8 @@ bool Server::SetAdvertisement(const std::vector<UUID>& ids,
                               const std::vector<uint8_t>& manufacturer_data,
                               bool transmit_name) {
   std::vector<uint8_t> id_data;
-  auto mutable_manufacturer_data = manufacturer_data;
-  auto mutable_service_data = service_data;
+  const auto& mutable_manufacturer_data = manufacturer_data;
+  const auto& mutable_service_data = service_data;
 
   for (const UUID &id : ids) {
     const auto le_id = id.GetFullLittleEndian();
@@ -612,8 +612,8 @@ bool Server::SetScanResponse(const std::vector<UUID>& ids,
                              const std::vector<uint8_t>& manufacturer_data,
                              bool transmit_name) {
   std::vector<uint8_t> id_data;
-  auto mutable_manufacturer_data = manufacturer_data;
-  auto mutable_service_data = service_data;
+  const auto& mutable_manufacturer_data = manufacturer_data;
+  const auto& mutable_service_data = service_data;
 
   for (const UUID &id : ids) {
     const auto le_id = id.GetFullLittleEndian();
index a5534dc..590b2b1 100644 (file)
@@ -80,7 +80,7 @@ void RegisterClientCallback(int status, int client_if, bt_uuid_t* app_uuid) {
       RegisterClientCallback(g_interface, status, client_if, *app_uuid));
 }
 
-void ScanResultCallback(bt_bdaddr_t* bda, int rssi, vector<uint8_t> adv_data) {
+void ScanResultCallback(bt_bdaddr_t* bda, int rssi, vector<uint8_t> adv_data) {  // NOLINT(pass-by-value)
   shared_lock<shared_timed_mutex> lock(g_instance_lock);
   VERIFY_INTERFACE_OR_RETURN();
   CHECK(bda);
@@ -288,7 +288,7 @@ void ConnectionCallback(int conn_id, int server_if, int connected,
 void ServiceAddedCallback(
     int status,
     int server_if,
-    vector<btgatt_db_element_t> service) {
+    vector<btgatt_db_element_t> service) {  // NOLINT(pass-by-value)
   shared_lock<shared_timed_mutex> lock(g_instance_lock);
   VLOG(2) << __func__ << " - status: " << status << " server_if: " << server_if
           << " count: " << service.size();
@@ -367,7 +367,7 @@ void RequestWriteDescriptorCallback(int conn_id, int trans_id,
                           bt_bdaddr_t* bda,
                           int attr_handle, int offset,
                           bool need_rsp, bool is_prep,
-                          vector<uint8_t> value) {
+                          vector<uint8_t> value) {  // NOLINT(pass-by-value)
   shared_lock<shared_timed_mutex> lock(g_instance_lock);
   VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id
           << " attr_handle: " << attr_handle << " offset: " << offset
@@ -596,7 +596,7 @@ void BluetoothGattInterface::ClientObserver::ScanResultCallback(
     BluetoothGattInterface* /* gatt_iface */,
     const bt_bdaddr_t& /* bda */,
     int /* rssi */,
-    vector<uint8_t>  /* adv_data */) {
+    vector<uint8_t>  /* adv_data */) {  // NOLINT(pass-by-value)
   // Do Nothing.
 }
 
@@ -742,7 +742,7 @@ void BluetoothGattInterface::ServerObserver::ServiceAddedCallback(
     BluetoothGattInterface* /* gatt_iface */,
     int /* status */,
     int /* server_if */,
-    vector<btgatt_db_element_t> /* service */) {
+    vector<btgatt_db_element_t> /* service */) {  // NOLINT(pass-by-value)
   // Do nothing.
 }
 
@@ -793,7 +793,7 @@ void BluetoothGattInterface::ServerObserver::RequestWriteCharacteristicCallback(
     int /* offset */,
     bool /* need_rsp */,
     bool /* is_prep */,
-    vector<uint8_t> /* value */) {
+    vector<uint8_t> /* value */) {  // NOLINT(pass-by-value)
   // Do nothing.
 }
 
@@ -806,7 +806,7 @@ void BluetoothGattInterface::ServerObserver::RequestWriteDescriptorCallback(
     int /* offset */,
     bool /* need_rsp */,
     bool /* is_prep */,
-    vector<uint8_t> /* value */) {
+    vector<uint8_t> /* value */) {  // NOLINT(pass-by-value)
   // Do nothing.
 }
 
index 509f863..8f072cd 100644 (file)
@@ -59,7 +59,7 @@ class BluetoothGattInterface {
     virtual void ScanResultCallback(
         BluetoothGattInterface* gatt_iface,
         const bt_bdaddr_t& bda, int rssi,
-        vector<uint8_t> adv_data);
+        vector<uint8_t> adv_data);  // NOLINT(pass-by-value)
 
     virtual void ConnectCallback(
         BluetoothGattInterface* gatt_iface,
@@ -158,7 +158,7 @@ class BluetoothGattInterface {
     virtual void ServiceAddedCallback(
         BluetoothGattInterface* gatt_iface,
         int status, int server_if,
-        vector<btgatt_db_element_t> service);
+        vector<btgatt_db_element_t> service);  // NOLINT(pass-by-value)
 
     virtual void ServiceStoppedCallback(
         BluetoothGattInterface* gatt_iface,
@@ -190,7 +190,7 @@ class BluetoothGattInterface {
         const bt_bdaddr_t& bda,
         int attr_handle, int offset,
         bool need_rsp, bool is_prep,
-        vector<uint8_t> value);
+        vector<uint8_t> value);  // NOLINT(pass-by-value)
 
     virtual void RequestWriteDescriptorCallback(
         BluetoothGattInterface* gatt_iface,
@@ -198,7 +198,7 @@ class BluetoothGattInterface {
         const bt_bdaddr_t& bda,
         int attr_handle, int offset,
         bool need_rsp, bool is_prep,
-        vector<uint8_t> value);
+        vector<uint8_t> value);  // NOLINT(pass-by-alue)
 
     virtual void RequestExecWriteCallback(
         BluetoothGattInterface* gatt_iface,
index 1dddb87..64c91d6 100644 (file)
@@ -75,9 +75,9 @@ bt_status_t FakeMultiAdvEnable(
 
 bt_status_t FakeMultiAdvSetInstData(
     int client_if, bool set_scan_rsp, bool include_name, bool incl_txpower,
-    int appearance, vector<uint8_t> manufacturer_data,
-    vector<uint8_t> service_data,
-    vector<uint8_t> service_uuid) {
+    int appearance, vector<uint8_t> manufacturer_data,  // NOLINT(pass-by-value)
+    vector<uint8_t> service_data,  // NOLINT(pass-by-value)
+    vector<uint8_t> service_uuid) {  // NOLINT(pass-by-value)
   if (g_client_handler)
     return g_client_handler->MultiAdvSetInstData(
         client_if, set_scan_rsp, include_name, incl_txpower, appearance,
@@ -238,7 +238,7 @@ void FakeBluetoothGattInterface::NotifyDisconnectCallback(
 }
 
 void FakeBluetoothGattInterface::NotifyScanResultCallback(
-    const bt_bdaddr_t& bda, int rssi, vector<uint8_t> adv_data) {
+    const bt_bdaddr_t& bda, int rssi, const vector<uint8_t>& adv_data) {
   FOR_EACH_OBSERVER(ClientObserver, client_observers_,
                     ScanResultCallback(this, bda, rssi, adv_data));
 }
@@ -269,7 +269,7 @@ void FakeBluetoothGattInterface::NotifyRegisterServerCallback(
 }
 
 void FakeBluetoothGattInterface::NotifyServerConnectionCallback(
-    int conn_id, int server_if, int connected, const bt_bdaddr_t& bda) {
+    int conn_id, int server_if, int connected, bt_bdaddr_t bda) {  // NOLINT(pass-by-value)
   FOR_EACH_OBSERVER(
       ServerObserver, server_observers_,
       ConnectionCallback(this, conn_id, server_if, connected, bda));
@@ -277,7 +277,7 @@ void FakeBluetoothGattInterface::NotifyServerConnectionCallback(
 
 void FakeBluetoothGattInterface::NotifyServiceAddedCallback(
     int status, int server_if,
-    vector<btgatt_db_element_t> service) {
+    vector<btgatt_db_element_t> service) {  // NOLINT(pass-by-value)
   FOR_EACH_OBSERVER(
       ServerObserver, server_observers_,
       ServiceAddedCallback(this, status, server_if, service));
@@ -303,7 +303,7 @@ void FakeBluetoothGattInterface::NotifyRequestReadDescriptorCallback(
 
 void FakeBluetoothGattInterface::NotifyRequestWriteCharacteristicCallback(
     int conn_id, int trans_id, const bt_bdaddr_t& bda, int attr_handle,
-    int offset, bool need_rsp, bool is_prep, vector<uint8_t> value) {
+    int offset, bool need_rsp, bool is_prep, vector<uint8_t> value) {  // NOLINT(pass-by-value)
   FOR_EACH_OBSERVER(
       ServerObserver, server_observers_,
       RequestWriteCharacteristicCallback(
@@ -315,7 +315,7 @@ void FakeBluetoothGattInterface::NotifyRequestWriteDescriptorCallback(
     int conn_id, int trans_id,
     const bt_bdaddr_t& bda, int attr_handle,
     int offset, bool need_rsp, bool is_prep,
-    vector<uint8_t> value) {
+    vector<uint8_t> value) {  // NOLINT(pass-by-value)
   FOR_EACH_OBSERVER(
       ServerObserver, server_observers_,
       RequestWriteDescriptorCallback(
index 2b39a97..4139846 100644 (file)
@@ -91,7 +91,7 @@ class FakeBluetoothGattInterface : public BluetoothGattInterface {
   void NotifyDisconnectCallback(int conn_id, int status, int client_if,
                                 const bt_bdaddr_t& bda);
   void NotifyScanResultCallback(const bt_bdaddr_t& bda, int rssi,
-                                vector<uint8_t> adv_data);
+                                const vector<uint8_t>& adv_data);
   void NotifyMultiAdvEnableCallback(int client_if, int status);
   void NotifyMultiAdvDataCallback(int client_if, int status);
   void NotifyMultiAdvDisableCallback(int client_if, int status);
@@ -101,9 +101,9 @@ class FakeBluetoothGattInterface : public BluetoothGattInterface {
                                     const bt_uuid_t& app_uuid);
   void NotifyServerConnectionCallback(int conn_id, int server_if,
                                       int connected,
-                                      const bt_bdaddr_t& bda);
+                                      bt_bdaddr_t bda);  // NOLINT(pass-by-value)
   void NotifyServiceAddedCallback(int status, int server_if,
-                                  vector<btgatt_db_element_t> srvc);
+                                  vector<btgatt_db_element_t> srvc);  // NOLINT(pass-by-value)
   void NotifyCharacteristicAddedCallback(int status, int server_if,
                                          const bt_uuid_t& uuid,
                                          int srvc_handle, int char_handle);
@@ -120,11 +120,11 @@ class FakeBluetoothGattInterface : public BluetoothGattInterface {
   void NotifyRequestWriteCharacteristicCallback(int conn_id, int trans_id,
                                   const bt_bdaddr_t& bda, int attr_handle,
                                   int offset, bool need_rsp, bool is_prep,
-                                  vector<uint8_t> value);
+                                  vector<uint8_t> value);  // NOLINT(pass-by-value)
   void NotifyRequestWriteDescriptorCallback(int conn_id, int trans_id,
                                   const bt_bdaddr_t& bda, int attr_handle,
                                   int offset, bool need_rsp, bool is_prep,
-                                  vector<uint8_t> value);
+                                  vector<uint8_t> value);  // NOLINT(pass-by-value)
   void NotifyRequestExecWriteCallback(int conn_id, int trans_id,
                                       const bt_bdaddr_t& bda, int exec_write);
   void NotifyIndicationSentCallback(int conn_id, int status);
index f85dc04..27695cc 100644 (file)
@@ -189,7 +189,7 @@ android::status_t BluetoothBinderServer::dump(
   VLOG(2) << __func__ << " called with fd " << fd;
   if (args.size() > 0) {
     // TODO (jamuraa): Parse arguments and switch on --proto, --proto_text
-    for (auto x : args) {
+    for (const auto& x : args) {
       VLOG(2) << __func__ << "argument: " << x.string();
     }
   }
index ea459f3..0ab9614 100644 (file)
@@ -132,7 +132,7 @@ Status BluetoothLowEnergyBinderServer::StartScan(
   }
 
   std::vector<bluetooth::ScanFilter> flt;
-  for (auto filter : filters) {
+  for (const auto& filter : filters) {
     flt.push_back(filter);
   }
 
@@ -173,7 +173,7 @@ Status BluetoothLowEnergyBinderServer::StartMultiAdvertising(
   // Create a weak pointer and pass that to the callback to prevent a potential
   // use after free.
   android::wp<BluetoothLowEnergyBinderServer> weak_ptr_to_this(this);
-  auto settings_copy = settings;
+  const auto& settings_copy = settings;
   auto callback = [=](bluetooth::BLEStatus status) {
     auto sp_to_this = weak_ptr_to_this.promote();
     if (!sp_to_this.get()) {
index 3e3107e..0ded432 100644 (file)
@@ -335,7 +335,7 @@ LowEnergyClient::~LowEnergyClient() {
     StopScan();
 }
 
-bool LowEnergyClient::Connect(std::string address, bool is_direct) {
+bool LowEnergyClient::Connect(const std::string& address, bool is_direct) {
   VLOG(2) << __func__ << "Address: " << address << " is_direct: " << is_direct;
 
   bt_bdaddr_t bda;
@@ -352,7 +352,7 @@ bool LowEnergyClient::Connect(std::string address, bool is_direct) {
   return true;
 }
 
-bool LowEnergyClient::Disconnect(std::string address) {
+bool LowEnergyClient::Disconnect(const std::string& address) {
   VLOG(2) << __func__ << "Address: " << address;
 
   bt_bdaddr_t bda;
@@ -378,7 +378,7 @@ bool LowEnergyClient::Disconnect(std::string address) {
   return true;
 }
 
-bool LowEnergyClient::SetMtu(std::string address, int mtu) {
+bool LowEnergyClient::SetMtu(const std::string& address, int mtu) {
   VLOG(2) << __func__ << "Address: " << address
           << " MTU: " << mtu;
 
index 2181fa4..1b31ea6 100644 (file)
@@ -87,15 +87,15 @@ class LowEnergyClient : private hal::BluetoothGattInterface::ClientObserver,
   // Initiates a BLE connection do device with address |address|. If
   // |is_direct| is set, use direct connect procedure. Return true on success
   //, false otherwise.
-  bool Connect(std::string address, bool is_direct);
+  bool Connect(const std::string& address, bool is_direct);
 
   // Disconnect from previously connected BLE device with address |address|.
   // Return true on success, false otherwise.
-  bool Disconnect(std::string address);
+  bool Disconnect(const std::string& address);
 
   // Sends request to set MTU to |mtu| for device with address |address|.
   // Return true on success, false otherwise.
-  bool SetMtu(std::string address, int mtu);
+  bool SetMtu(const std::string& address, int mtu);
 
   // Initiates a BLE device scan for this client using the given |settings| and
   // |filters|. See the documentation for ScanSettings and ScanFilter for how
index 0251e99..22cfbec 100644 (file)
@@ -51,8 +51,8 @@ class MockGattHandler
   MOCK_METHOD7(MultiAdvEnable, bt_status_t(int, int, int, int, int, int, int));
   MOCK_METHOD7(
       MultiAdvSetInstDataMock,
-      bt_status_t(bool, bool, bool, int, vector<uint8_t>, vector<uint8_t>,
-                  vector<uint8_t>));
+      bt_status_t(bool, bool, bool, int, const vector<uint8_t>&, const vector<uint8_t>&,
+                  const vector<uint8_t>&));
   MOCK_METHOD1(MultiAdvDisable, bt_status_t(int));
 
   // GMock has macros for up to 10 arguments (11 is really just too many...).
@@ -212,7 +212,7 @@ class LowEnergyClientPostRegisterTest : public LowEnergyClientTest {
   }
 
   void RegisterTestClient(
-      const std::function<void(std::unique_ptr<LowEnergyClient> client)>
+      const std::function<void(std::unique_ptr<LowEnergyClient> client)>&
           callback) {
     UUID uuid = UUID::GetRandom();
     auto api_callback = [&](BLEStatus status, const UUID& in_uuid,
@@ -266,7 +266,7 @@ class LowEnergyClientPostRegisterTest : public LowEnergyClientTest {
     ASSERT_FALSE(le_client_->IsStoppingAdvertising());
   }
 
-  void AdvertiseDataTestHelper(AdvertiseData data, std::function<void(BLEStatus)> callback) {
+  void AdvertiseDataTestHelper(const AdvertiseData& data, const std::function<void(BLEStatus)>& callback) {
     AdvertiseSettings settings;
     EXPECT_TRUE(le_client_->StartAdvertising(
         settings, data, AdvertiseData(), callback));
index b3884e6..87822e3 100644 (file)
@@ -185,11 +185,11 @@ class DualModeController {
   // TODO(dennischeng): Once PostDelayedTask works, get rid of this and only use
   // |RegisterDelayedEventChannel|.
   void RegisterEventChannel(
-      std::function<void(std::unique_ptr<EventPacket>)> send_event);
+      const std::function<void(std::unique_ptr<EventPacket>)>& send_event);
 
   void RegisterDelayedEventChannel(
-      std::function<void(std::unique_ptr<EventPacket>,
-                         std::chrono::milliseconds)> send_event);
+      const std::function<void(std::unique_ptr<EventPacket>,
+                         std::chrono::milliseconds)>& send_event);
 
   // Controller commands. For error codes, see the Bluetooth Core Specification,
   // Version 4.2, Volume 2, Part D (page 370).
index 3d9c5f2..9215982 100644 (file)
@@ -57,7 +57,7 @@ class EventPacket : public Packet {
 
   // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12
   static std::unique_ptr<EventPacket> CreateCommandCompleteReadLocalName(
-      const uint8_t status, const std::string local_name);
+      const uint8_t status, const std::string& local_name);
 
   // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.4.1
   static std::unique_ptr<EventPacket>
index e90f5a0..4477453 100644 (file)
@@ -57,18 +57,18 @@ class HciTransport {
 
   // Sets the callback that is run when command packets are received.
   void RegisterCommandHandler(
-      std::function<void(std::unique_ptr<CommandPacket>)> callback);
+      const std::function<void(std::unique_ptr<CommandPacket>)>& callback);
 
   // Sets the callback that is to schedule events.
   void RegisterEventScheduler(
-      std::function<void(std::chrono::milliseconds, const TaskCallback&)>
+      const std::function<void(std::chrono::milliseconds, const TaskCallback&)>&
           evtScheduler);
 
   // Sets the callback that is to schedule events.
   void RegisterPeriodicEventScheduler(
-      std::function<void(std::chrono::milliseconds,
+      const std::function<void(std::chrono::milliseconds,
                          std::chrono::milliseconds,
-                         const TaskCallback&)> periodicEvtScheduler);
+                         const TaskCallback&)>& periodicEvtScheduler);
 
   // Posts the event onto |outbound_events_| to be written sometime in the
   // future when the vendor file descriptor is ready for writing.
index 0460cbd..8f4d4e8 100644 (file)
@@ -54,7 +54,7 @@ class TestChannelTransport {
   // Sets the callback that fires when data is read in
   // |OnFileCanReadWithoutBlocking|.
   void RegisterCommandHandler(
-      std::function<void(const std::string&, const vector<std::string>&)>
+      const std::function<void(const std::string&, const vector<std::string>&)>&
           callback);
 
   void OnFileCanReadWithoutBlocking(int fd);
index 126dddf..3b4afbd 100644 (file)
@@ -348,7 +348,7 @@ class AsyncManager::AsyncTaskManager {
   AsyncTaskManager(const AsyncTaskManager&) = delete;
   AsyncTaskManager& operator=(const AsyncTaskManager&) = delete;
 
-  AsyncTaskId scheduleTask(std::shared_ptr<Task> task) {
+  AsyncTaskId scheduleTask(const std::shared_ptr<Task>& task) {
     AsyncTaskId task_id = kInvalidTaskId;
     {
       std::unique_lock<std::mutex> guard(internal_mutex_);
index d48cb48..70ba313 100644 (file)
@@ -205,12 +205,12 @@ void DualModeController::HandleCommand(
 }
 
 void DualModeController::RegisterEventChannel(
-    std::function<void(std::unique_ptr<EventPacket>)> callback) {
+    const std::function<void(std::unique_ptr<EventPacket>)>& callback) {
   send_event_ = callback;
 }
 
 void DualModeController::RegisterDelayedEventChannel(
-    std::function<void(std::unique_ptr<EventPacket>, std::chrono::milliseconds)>
+    const std::function<void(std::unique_ptr<EventPacket>, std::chrono::milliseconds)>&
         callback) {
   send_delayed_event_ = callback;
   SetEventDelay(0);
index 4b9eb7e..02a3253 100644 (file)
@@ -84,7 +84,7 @@ std::unique_ptr<EventPacket> EventPacket::CreateCommandStatusEvent(
 
 // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12
 std::unique_ptr<EventPacket> EventPacket::CreateCommandCompleteReadLocalName(
-    const uint8_t status, const std::string local_name) {
+    const uint8_t status, const std::string& local_name) {
   std::unique_ptr<EventPacket> evt_ptr =
       EventPacket::CreateCommandCompleteOnlyStatusEvent(HCI_READ_LOCAL_NAME,
                                                         status);
index d5015ea..926c5aa 100644 (file)
@@ -95,20 +95,20 @@ void HciTransport::ReceiveReadyCommand() const {
 }
 
 void HciTransport::RegisterCommandHandler(
-    std::function<void(std::unique_ptr<CommandPacket>)> callback) {
+    const std::function<void(std::unique_ptr<CommandPacket>)>& callback) {
   command_handler_ = callback;
 }
 
 void HciTransport::RegisterEventScheduler(
-    std::function<void(std::chrono::milliseconds, const TaskCallback&)>
+    const std::function<void(std::chrono::milliseconds, const TaskCallback&)>&
         evtScheduler) {
   schedule_event_ = evtScheduler;
 }
 
 void HciTransport::RegisterPeriodicEventScheduler(
-    std::function<void(std::chrono::milliseconds,
+    const std::function<void(std::chrono::milliseconds,
                        std::chrono::milliseconds,
-                       const TaskCallback&)> periodicEvtScheduler) {
+                       const TaskCallback&)>& periodicEvtScheduler) {
   schedule_periodic_event_ = periodicEvtScheduler;
 }
 
index 2572c06..906a177 100644 (file)
@@ -126,7 +126,7 @@ void TestChannelTransport::OnFileCanReadWithoutBlocking(int fd) {
 }
 
 void TestChannelTransport::RegisterCommandHandler(
-    std::function<void(const std::string&, const vector<std::string>&)>
+    const std::function<void(const std::string&, const vector<std::string>&)>&
         callback) {
   command_handler_ = callback;
 }