From: Chih-Hung Hsieh Date: Wed, 17 Aug 2016 21:12:51 +0000 (-0700) Subject: Fix clang-tidy warnings in bt. X-Git-Tag: android-x86-8.1-r1~196^2~67^2~174^2~261 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5dc0d15e78;p=android-x86%2Fsystem-bt.git Fix clang-tidy warnings in bt. * 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 --- diff --git a/service/client/main.cc b/service/client/main.cc index 103bb474b..d85e2b680 100644 --- a/service/client/main.cc +++ b/service/client/main.cc @@ -700,7 +700,7 @@ void HandleStartLeScan(IBluetooth* bt_iface, const vector& 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& /* args */) { const char kExecuteLong[] = "exec"; const char kExecuteShort[] = "e"; -bool ExecuteCommand(sp bt_iface, std::string &command) { +bool ExecuteCommand(const sp& bt_iface, std::string &command) { vector args = base::SplitString(command, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); diff --git a/service/common/android/bluetooth/bluetooth_gatt_characteristic.h b/service/common/android/bluetooth/bluetooth_gatt_characteristic.h index 95300a78a..2286068ee 100644 --- a/service/common/android/bluetooth/bluetooth_gatt_characteristic.h +++ b/service/common/android/bluetooth/bluetooth_gatt_characteristic.h @@ -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; diff --git a/service/common/android/bluetooth/bluetooth_gatt_descriptor.h b/service/common/android/bluetooth/bluetooth_gatt_descriptor.h index 8f9385d53..c791c242f 100644 --- a/service/common/android/bluetooth/bluetooth_gatt_descriptor.h +++ b/service/common/android/bluetooth/bluetooth_gatt_descriptor.h @@ -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; diff --git a/service/common/android/bluetooth/bluetooth_gatt_included_service.h b/service/common/android/bluetooth/bluetooth_gatt_included_service.h index 2692020b8..7ff344f5d 100644 --- a/service/common/android/bluetooth/bluetooth_gatt_included_service.h +++ b/service/common/android/bluetooth/bluetooth_gatt_included_service.h @@ -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; diff --git a/service/common/android/bluetooth/bluetooth_gatt_service.h b/service/common/android/bluetooth/bluetooth_gatt_service.h index f9d9392c7..eb6a30e58 100644 --- a/service/common/android/bluetooth/bluetooth_gatt_service.h +++ b/service/common/android/bluetooth/bluetooth_gatt_service.h @@ -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; diff --git a/service/common/bluetooth/scan_result.cc b/service/common/bluetooth/scan_result.cc index 76567786b..9e28e416d 100644 --- a/service/common/bluetooth/scan_result.cc +++ b/service/common/bluetooth/scan_result.cc @@ -24,7 +24,7 @@ namespace bluetooth { ScanResult::ScanResult(const std::string& device_address, - const std::vector scan_record, + const std::vector& scan_record, int rssi) : device_address_(device_address), scan_record_(scan_record), diff --git a/service/common/bluetooth/scan_result.h b/service/common/bluetooth/scan_result.h index 3ba88f6d1..9be25b530 100644 --- a/service/common/bluetooth/scan_result.h +++ b/service/common/bluetooth/scan_result.h @@ -28,7 +28,7 @@ namespace bluetooth { class ScanResult { public: ScanResult(const std::string& device_address, - const std::vector scan_record, + const std::vector& scan_record, int rssi); ScanResult() = default; ~ScanResult() = default; diff --git a/service/gatt_server.cc b/service/gatt_server.cc index 9a76f6624..57ac6bad4 100644 --- a/service/gatt_server.cc +++ b/service/gatt_server.cc @@ -147,7 +147,7 @@ bool GattServer::SendResponse( } std::shared_ptr 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()) { diff --git a/service/gatt_server_old.cc b/service/gatt_server_old.cc index 9f196a8af..dcc941c41 100644 --- a/service/gatt_server_old.cc +++ b/service/gatt_server_old.cc @@ -580,8 +580,8 @@ bool Server::SetAdvertisement(const std::vector& ids, const std::vector& manufacturer_data, bool transmit_name) { std::vector 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& ids, const std::vector& manufacturer_data, bool transmit_name) { std::vector 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(); diff --git a/service/hal/bluetooth_gatt_interface.cc b/service/hal/bluetooth_gatt_interface.cc index a5534dcb0..590b2b149 100644 --- a/service/hal/bluetooth_gatt_interface.cc +++ b/service/hal/bluetooth_gatt_interface.cc @@ -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 adv_data) { +void ScanResultCallback(bt_bdaddr_t* bda, int rssi, vector adv_data) { // NOLINT(pass-by-value) shared_lock 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 service) { + vector service) { // NOLINT(pass-by-value) shared_lock 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 value) { + vector value) { // NOLINT(pass-by-value) shared_lock 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 /* adv_data */) { + vector /* 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 /* service */) { + vector /* service */) { // NOLINT(pass-by-value) // Do nothing. } @@ -793,7 +793,7 @@ void BluetoothGattInterface::ServerObserver::RequestWriteCharacteristicCallback( int /* offset */, bool /* need_rsp */, bool /* is_prep */, - vector /* value */) { + vector /* value */) { // NOLINT(pass-by-value) // Do nothing. } @@ -806,7 +806,7 @@ void BluetoothGattInterface::ServerObserver::RequestWriteDescriptorCallback( int /* offset */, bool /* need_rsp */, bool /* is_prep */, - vector /* value */) { + vector /* value */) { // NOLINT(pass-by-value) // Do nothing. } diff --git a/service/hal/bluetooth_gatt_interface.h b/service/hal/bluetooth_gatt_interface.h index 509f863db..8f072cda2 100644 --- a/service/hal/bluetooth_gatt_interface.h +++ b/service/hal/bluetooth_gatt_interface.h @@ -59,7 +59,7 @@ class BluetoothGattInterface { virtual void ScanResultCallback( BluetoothGattInterface* gatt_iface, const bt_bdaddr_t& bda, int rssi, - vector adv_data); + vector 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 service); + vector 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 value); + vector 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 value); + vector value); // NOLINT(pass-by-alue) virtual void RequestExecWriteCallback( BluetoothGattInterface* gatt_iface, diff --git a/service/hal/fake_bluetooth_gatt_interface.cc b/service/hal/fake_bluetooth_gatt_interface.cc index 1dddb8709..64c91d68f 100644 --- a/service/hal/fake_bluetooth_gatt_interface.cc +++ b/service/hal/fake_bluetooth_gatt_interface.cc @@ -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 manufacturer_data, - vector service_data, - vector service_uuid) { + int appearance, vector manufacturer_data, // NOLINT(pass-by-value) + vector service_data, // NOLINT(pass-by-value) + vector 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 adv_data) { + const bt_bdaddr_t& bda, int rssi, const vector& 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 service) { + vector 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 value) { + int offset, bool need_rsp, bool is_prep, vector 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 value) { + vector value) { // NOLINT(pass-by-value) FOR_EACH_OBSERVER( ServerObserver, server_observers_, RequestWriteDescriptorCallback( diff --git a/service/hal/fake_bluetooth_gatt_interface.h b/service/hal/fake_bluetooth_gatt_interface.h index 2b39a97ca..413984689 100644 --- a/service/hal/fake_bluetooth_gatt_interface.h +++ b/service/hal/fake_bluetooth_gatt_interface.h @@ -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 adv_data); + const vector& 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 srvc); + vector 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 value); + vector 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 value); + vector 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); diff --git a/service/ipc/binder/bluetooth_binder_server.cc b/service/ipc/binder/bluetooth_binder_server.cc index f85dc04ac..27695cc95 100644 --- a/service/ipc/binder/bluetooth_binder_server.cc +++ b/service/ipc/binder/bluetooth_binder_server.cc @@ -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(); } } diff --git a/service/ipc/binder/bluetooth_low_energy_binder_server.cc b/service/ipc/binder/bluetooth_low_energy_binder_server.cc index ea459f3e4..0ab961427 100644 --- a/service/ipc/binder/bluetooth_low_energy_binder_server.cc +++ b/service/ipc/binder/bluetooth_low_energy_binder_server.cc @@ -132,7 +132,7 @@ Status BluetoothLowEnergyBinderServer::StartScan( } std::vector 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 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()) { diff --git a/service/low_energy_client.cc b/service/low_energy_client.cc index 3e3107e44..0ded432b1 100644 --- a/service/low_energy_client.cc +++ b/service/low_energy_client.cc @@ -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; diff --git a/service/low_energy_client.h b/service/low_energy_client.h index 2181fa420..1b31ea612 100644 --- a/service/low_energy_client.h +++ b/service/low_energy_client.h @@ -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 diff --git a/service/test/low_energy_client_unittest.cc b/service/test/low_energy_client_unittest.cc index 0251e9931..22cfbec4a 100644 --- a/service/test/low_energy_client_unittest.cc +++ b/service/test/low_energy_client_unittest.cc @@ -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, vector, - vector)); + bt_status_t(bool, bool, bool, int, const vector&, const vector&, + const vector&)); 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 client)> + const std::function 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 callback) { + void AdvertiseDataTestHelper(const AdvertiseData& data, const std::function& callback) { AdvertiseSettings settings; EXPECT_TRUE(le_client_->StartAdvertising( settings, data, AdvertiseData(), callback)); diff --git a/vendor_libs/test_vendor_lib/include/dual_mode_controller.h b/vendor_libs/test_vendor_lib/include/dual_mode_controller.h index b3884e6c2..87822e3ad 100644 --- a/vendor_libs/test_vendor_lib/include/dual_mode_controller.h +++ b/vendor_libs/test_vendor_lib/include/dual_mode_controller.h @@ -185,11 +185,11 @@ class DualModeController { // TODO(dennischeng): Once PostDelayedTask works, get rid of this and only use // |RegisterDelayedEventChannel|. void RegisterEventChannel( - std::function)> send_event); + const std::function)>& send_event); void RegisterDelayedEventChannel( - std::function, - std::chrono::milliseconds)> send_event); + const std::function, + std::chrono::milliseconds)>& send_event); // Controller commands. For error codes, see the Bluetooth Core Specification, // Version 4.2, Volume 2, Part D (page 370). diff --git a/vendor_libs/test_vendor_lib/include/event_packet.h b/vendor_libs/test_vendor_lib/include/event_packet.h index 3d9c5f27d..921598250 100644 --- a/vendor_libs/test_vendor_lib/include/event_packet.h +++ b/vendor_libs/test_vendor_lib/include/event_packet.h @@ -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 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 diff --git a/vendor_libs/test_vendor_lib/include/hci_transport.h b/vendor_libs/test_vendor_lib/include/hci_transport.h index e90f5a0e0..44774533d 100644 --- a/vendor_libs/test_vendor_lib/include/hci_transport.h +++ b/vendor_libs/test_vendor_lib/include/hci_transport.h @@ -57,18 +57,18 @@ class HciTransport { // Sets the callback that is run when command packets are received. void RegisterCommandHandler( - std::function)> callback); + const std::function)>& callback); // Sets the callback that is to schedule events. void RegisterEventScheduler( - std::function + const std::function& evtScheduler); // Sets the callback that is to schedule events. void RegisterPeriodicEventScheduler( - std::function 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. diff --git a/vendor_libs/test_vendor_lib/include/test_channel_transport.h b/vendor_libs/test_vendor_lib/include/test_channel_transport.h index 0460cbdb4..8f4d4e849 100644 --- a/vendor_libs/test_vendor_lib/include/test_channel_transport.h +++ b/vendor_libs/test_vendor_lib/include/test_channel_transport.h @@ -54,7 +54,7 @@ class TestChannelTransport { // Sets the callback that fires when data is read in // |OnFileCanReadWithoutBlocking|. void RegisterCommandHandler( - std::function&)> + const std::function&)>& callback); void OnFileCanReadWithoutBlocking(int fd); diff --git a/vendor_libs/test_vendor_lib/src/async_manager.cc b/vendor_libs/test_vendor_lib/src/async_manager.cc index 126dddfe6..3b4afbdfb 100644 --- a/vendor_libs/test_vendor_lib/src/async_manager.cc +++ b/vendor_libs/test_vendor_lib/src/async_manager.cc @@ -348,7 +348,7 @@ class AsyncManager::AsyncTaskManager { AsyncTaskManager(const AsyncTaskManager&) = delete; AsyncTaskManager& operator=(const AsyncTaskManager&) = delete; - AsyncTaskId scheduleTask(std::shared_ptr task) { + AsyncTaskId scheduleTask(const std::shared_ptr& task) { AsyncTaskId task_id = kInvalidTaskId; { std::unique_lock guard(internal_mutex_); diff --git a/vendor_libs/test_vendor_lib/src/dual_mode_controller.cc b/vendor_libs/test_vendor_lib/src/dual_mode_controller.cc index d48cb485a..70ba31357 100644 --- a/vendor_libs/test_vendor_lib/src/dual_mode_controller.cc +++ b/vendor_libs/test_vendor_lib/src/dual_mode_controller.cc @@ -205,12 +205,12 @@ void DualModeController::HandleCommand( } void DualModeController::RegisterEventChannel( - std::function)> callback) { + const std::function)>& callback) { send_event_ = callback; } void DualModeController::RegisterDelayedEventChannel( - std::function, std::chrono::milliseconds)> + const std::function, std::chrono::milliseconds)>& callback) { send_delayed_event_ = callback; SetEventDelay(0); diff --git a/vendor_libs/test_vendor_lib/src/event_packet.cc b/vendor_libs/test_vendor_lib/src/event_packet.cc index 4b9eb7e9b..02a325364 100644 --- a/vendor_libs/test_vendor_lib/src/event_packet.cc +++ b/vendor_libs/test_vendor_lib/src/event_packet.cc @@ -84,7 +84,7 @@ std::unique_ptr EventPacket::CreateCommandStatusEvent( // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12 std::unique_ptr EventPacket::CreateCommandCompleteReadLocalName( - const uint8_t status, const std::string local_name) { + const uint8_t status, const std::string& local_name) { std::unique_ptr evt_ptr = EventPacket::CreateCommandCompleteOnlyStatusEvent(HCI_READ_LOCAL_NAME, status); diff --git a/vendor_libs/test_vendor_lib/src/hci_transport.cc b/vendor_libs/test_vendor_lib/src/hci_transport.cc index d5015ea5d..926c5aa1f 100644 --- a/vendor_libs/test_vendor_lib/src/hci_transport.cc +++ b/vendor_libs/test_vendor_lib/src/hci_transport.cc @@ -95,20 +95,20 @@ void HciTransport::ReceiveReadyCommand() const { } void HciTransport::RegisterCommandHandler( - std::function)> callback) { + const std::function)>& callback) { command_handler_ = callback; } void HciTransport::RegisterEventScheduler( - std::function + const std::function& evtScheduler) { schedule_event_ = evtScheduler; } void HciTransport::RegisterPeriodicEventScheduler( - std::function periodicEvtScheduler) { + const TaskCallback&)>& periodicEvtScheduler) { schedule_periodic_event_ = periodicEvtScheduler; } diff --git a/vendor_libs/test_vendor_lib/src/test_channel_transport.cc b/vendor_libs/test_vendor_lib/src/test_channel_transport.cc index 2572c06a6..906a1774a 100644 --- a/vendor_libs/test_vendor_lib/src/test_channel_transport.cc +++ b/vendor_libs/test_vendor_lib/src/test_channel_transport.cc @@ -126,7 +126,7 @@ void TestChannelTransport::OnFileCanReadWithoutBlocking(int fd) { } void TestChannelTransport::RegisterCommandHandler( - std::function&)> + const std::function&)>& callback) { command_handler_ = callback; }