diff options
author | Sven Gothel <[email protected]> | 2022-11-28 22:01:56 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-11-28 22:01:56 +0100 |
commit | 542369fe13a535b817a42f890f51e1ca09ba552c (patch) | |
tree | b732befc4c69d8b7882d07725ba4f75861182cac /api | |
parent | 9d863d14db95d3c30f0b41b8ce3ed89275934f1d (diff) |
clang-tidy fixes part-3 / 4, adding Check `performance-*`
See also jaulib commit 9160f9a4b74f5e5ae07f715025ea4d3aafdf6ab3
Details:
- Using 'const T&' as method argument type where applicable, i.e. not when required to pass value off-thread.
- Notable: Can also hold a default value!
- Using `const T&` in range-loop where applicable
- Drop std::move for trivial types
- ...
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/ATTPDUTypes.hpp | 10 | ||||
-rw-r--r-- | api/direct_bt/BTAdapter.hpp | 18 | ||||
-rw-r--r-- | api/direct_bt/BTAddress.hpp | 8 | ||||
-rw-r--r-- | api/direct_bt/BTDevice.hpp | 10 | ||||
-rw-r--r-- | api/direct_bt/BTDeviceRegistry.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/BTGattHandler.hpp | 10 | ||||
-rw-r--r-- | api/direct_bt/BTManager.hpp | 3 | ||||
-rw-r--r-- | api/direct_bt/BTSecurityRegistry.hpp | 6 | ||||
-rw-r--r-- | api/direct_bt/BTTypes0.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/BTTypes1.hpp | 16 | ||||
-rw-r--r-- | api/direct_bt/DBGattServer.hpp | 20 | ||||
-rw-r--r-- | api/direct_bt/HCIComm.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/HCIHandler.hpp | 4 | ||||
-rw-r--r-- | api/direct_bt/HCITypes.hpp | 10 | ||||
-rw-r--r-- | api/direct_bt/L2CAPComm.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/MgmtTypes.hpp | 8 | ||||
-rw-r--r-- | api/direct_bt/SMPTypes.hpp | 12 | ||||
-rw-r--r-- | api/direct_bt/ieee11073/DataTypes.hpp | 12 |
18 files changed, 80 insertions, 75 deletions
diff --git a/api/direct_bt/ATTPDUTypes.hpp b/api/direct_bt/ATTPDUTypes.hpp index 1c7e36ed..b684e984 100644 --- a/api/direct_bt/ATTPDUTypes.hpp +++ b/api/direct_bt/ATTPDUTypes.hpp @@ -204,23 +204,23 @@ namespace direct_bt { class AttException : public jau::RuntimeException { protected: - AttException(std::string const type, std::string const m, const char* file, int line) noexcept - : RuntimeException(type, m, file, line) {} + AttException(std::string type, std::string const& m, const char* file, int line) noexcept + : RuntimeException(std::move(type), m, file, line) {} public: - AttException(std::string const m, const char* file, int line) noexcept + AttException(std::string const& m, const char* file, int line) noexcept : RuntimeException("AttException", m, file, line) {} }; class AttOpcodeException : public AttException { public: - AttOpcodeException(std::string const m, const char* file, int line) noexcept + AttOpcodeException(std::string const& m, const char* file, int line) noexcept : AttException("AttOpcodeException", m, file, line) {} }; class AttValueException : public AttException { public: - AttValueException(std::string const m, const char* file, int line) noexcept + AttValueException(std::string const& m, const char* file, int line) noexcept : AttException("AttValueException", m, file, line) {} }; diff --git a/api/direct_bt/BTAdapter.hpp b/api/direct_bt/BTAdapter.hpp index 5915241b..b8613626 100644 --- a/api/direct_bt/BTAdapter.hpp +++ b/api/direct_bt/BTAdapter.hpp @@ -472,10 +472,10 @@ namespace direct_bt { uint16_t latency, uint16_t supervision_timeout) noexcept; friend HCIStatusCode BTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch) noexcept; friend void BTDevice::processL2CAPSetup(BTDeviceRef sthis); - friend bool BTDevice::updatePairingState(BTDeviceRef sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept; - friend void BTDevice::hciSMPMsgCallback(BTDeviceRef sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept; + friend bool BTDevice::updatePairingState(const BTDeviceRef& sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept; + friend void BTDevice::hciSMPMsgCallback(const BTDeviceRef& sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept; friend void BTDevice::processDeviceReady(BTDeviceRef sthis, const uint64_t timestamp); - friend bool BTDevice::connectGATT(std::shared_ptr<BTDevice> sthis) noexcept; + friend bool BTDevice::connectGATT(const std::shared_ptr<BTDevice>& sthis) noexcept; friend jau::darray<BTGattServiceRef> BTDevice::getGattServices() noexcept; bool lockConnect(const BTDevice & device, const bool wait, const SMPIOCapability io_cap) noexcept; @@ -502,7 +502,7 @@ namespace direct_bt { void removeSharedDevice(const BTDevice & device) noexcept; static SMPKeyBinRef findSMPKeyBin(key_list_t & keys, BDAddressAndType const & remoteAddress) noexcept; - static bool removeSMPKeyBin(key_list_t & keys, BDAddressAndType const & remoteAddress, const bool remove_file, const std::string key_path_) noexcept; + static bool removeSMPKeyBin(key_list_t & keys, BDAddressAndType const & remoteAddress, const bool remove_file, const std::string& key_path_) noexcept; SMPKeyBinRef findSMPKeyBin(BDAddressAndType const & remoteAddress) noexcept; /** Adding a SMPKeyBin will remove previous entry. */ bool addSMPKeyBin(const SMPKeyBinRef& key, const bool write_file) noexcept; @@ -516,7 +516,7 @@ namespace direct_bt { void l2capServerWork(jau::service_runner& sr) noexcept; void l2capServerInit(jau::service_runner& sr) noexcept; void l2capServerEnd(jau::service_runner& sr) noexcept; - std::unique_ptr<L2CAPClient> get_l2cap_connection(std::shared_ptr<BTDevice> device); + std::unique_ptr<L2CAPClient> get_l2cap_connection(const std::shared_ptr<BTDevice>& device); void mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept; void updateAdapterSettings(const bool off_thread, const AdapterSetting new_settings, const bool sendEvent, const uint64_t timestamp) noexcept; @@ -558,8 +558,8 @@ namespace direct_bt { void hciSMPMsgCallback(const BDAddressAndType & addressAndType, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept; - void sendDevicePairingState(BTDeviceRef device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept; - void notifyPairingStageDone(BTDeviceRef device, uint64_t timestamp) noexcept; + void sendDevicePairingState(const BTDeviceRef& device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept; + void notifyPairingStageDone(const BTDeviceRef& device, uint64_t timestamp) noexcept; void sendDeviceReady(BTDeviceRef device, uint64_t timestamp) noexcept; jau::service_runner discovery_service; @@ -1208,7 +1208,7 @@ namespace direct_bt { * @see DBGattServer::setServicesHandles() * @since 2.5.3 */ - HCIStatusCode startAdvertising(DBGattServerRef gattServerData_, + HCIStatusCode startAdvertising(const DBGattServerRef& gattServerData_, EInfoReport& eir, EIRDataType adv_mask = EIRDataType::FLAGS | EIRDataType::SERVICE_UUID, EIRDataType scanrsp_mask = EIRDataType::NAME | EIRDataType::CONN_IVAL, @@ -1260,7 +1260,7 @@ namespace direct_bt { * @see DBGattServer::setServicesHandles() * @since 2.4.0 */ - HCIStatusCode startAdvertising(DBGattServerRef gattServerData_, + HCIStatusCode startAdvertising(const DBGattServerRef& gattServerData_, const uint16_t adv_interval_min=160, const uint16_t adv_interval_max=480, const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND, const uint8_t adv_chan_map=0x07, diff --git a/api/direct_bt/BTAddress.hpp b/api/direct_bt/BTAddress.hpp index 6fa7b0b2..29530adf 100644 --- a/api/direct_bt/BTAddress.hpp +++ b/api/direct_bt/BTAddress.hpp @@ -196,8 +196,8 @@ namespace direct_bt { constexpr BDAddressAndType() noexcept : address(), type{BDAddressType::BDADDR_UNDEFINED} { } BDAddressAndType(const BDAddressAndType &o) noexcept : address(o.address), type(o.type) { } BDAddressAndType(BDAddressAndType &&o) noexcept { - address = std::move(o.address); - type = std::move(o.type); + address = o.address; + type = o.type; } constexpr BDAddressAndType& operator=(const BDAddressAndType &o) noexcept { address = o.address; @@ -205,8 +205,8 @@ namespace direct_bt { return *this; } BDAddressAndType& operator=(BDAddressAndType &&o) noexcept { - address = std::move(o.address); - type = std::move(o.type); + address = o.address; + type = o.type; return *this; } diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp index d4c7ba7e..e4528c4c 100644 --- a/api/direct_bt/BTDevice.hpp +++ b/api/direct_bt/BTDevice.hpp @@ -170,8 +170,8 @@ namespace direct_bt { EIRDataType update(GattGenericAccessSvc const &data, const uint64_t timestamp) noexcept; void notifyDisconnected() noexcept; - void notifyConnected(std::shared_ptr<BTDevice> sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept; - void notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const LE_Features features) noexcept; + void notifyConnected(const std::shared_ptr<BTDevice>& sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept; + void notifyLEFeatures(const std::shared_ptr<BTDevice>& sthis, const LE_Features features) noexcept; void notifyLEPhyUpdateComplete(const HCIStatusCode status, const LE_PHYs Tx, const LE_PHYs Rx) noexcept; /** @@ -203,7 +203,7 @@ namespace direct_bt { bool checkPairingKeyDistributionComplete() const noexcept; - bool updatePairingState(std::shared_ptr<BTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept; + bool updatePairingState(const std::shared_ptr<BTDevice>& sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept; /** * Forwarded from HCIHandler -> BTAdapter -> this BTDevice @@ -211,7 +211,7 @@ namespace direct_bt { * Will be initiated by processL2CAPSetup()'s security_level setup after connectLE(..), i.e. notifyConnected() and notifyLEFeatures(). * </p> */ - void hciSMPMsgCallback(std::shared_ptr<BTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept; + void hciSMPMsgCallback(const std::shared_ptr<BTDevice>& sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept; /** * Setup GATT via connectGATT() off-thread. @@ -232,7 +232,7 @@ namespace direct_bt { * The GATTHandler is managed by this device instance and closed via disconnectGATT(). * </p> */ - bool connectGATT(std::shared_ptr<BTDevice> sthis) noexcept; + bool connectGATT(const std::shared_ptr<BTDevice>& sthis) noexcept; /** * Will be performed within disconnect() and notifyDisconnected(). diff --git a/api/direct_bt/BTDeviceRegistry.hpp b/api/direct_bt/BTDeviceRegistry.hpp index 8112d2a7..7f56a68e 100644 --- a/api/direct_bt/BTDeviceRegistry.hpp +++ b/api/direct_bt/BTDeviceRegistry.hpp @@ -61,7 +61,7 @@ namespace direct_bt { EUI48Sub addressSub; std::string nameSub; - DeviceQuery(EUI48Sub as) : type(Type::EUI48SUB), addressSub(std::move(as)), nameSub() {} + DeviceQuery(const EUI48Sub& as) : type(Type::EUI48SUB), addressSub(as), nameSub() {} DeviceQuery(std::string ns) : type(Type::NAME), addressSub(EUI48Sub::ANY_DEVICE), nameSub(std::move(ns)) {} diff --git a/api/direct_bt/BTGattHandler.hpp b/api/direct_bt/BTGattHandler.hpp index 8b42f5bb..d19c1b31 100644 --- a/api/direct_bt/BTGattHandler.hpp +++ b/api/direct_bt/BTGattHandler.hpp @@ -496,7 +496,7 @@ namespace direct_bt { DBGattServerRef gattServerData; /** Always set, never nullptr */ std::unique_ptr<GattServerHandler> gattServerHandler; - static std::unique_ptr<GattServerHandler> selectGattServerHandler(BTGattHandler& gh, DBGattServerRef gattServerData) noexcept; + static std::unique_ptr<GattServerHandler> selectGattServerHandler(BTGattHandler& gh, const DBGattServerRef& gattServerData) noexcept; GattServiceList_t services; std::shared_ptr<GattGenericAccessSvc> genericAccess = nullptr; @@ -538,7 +538,7 @@ namespace direct_bt { * @see initClientGatt() * @see discoverCompletePrimaryServices() */ - bool discoverPrimaryServices(std::shared_ptr<BTGattHandler> shared_this, GattServiceList_t& result) noexcept; + bool discoverPrimaryServices(const std::shared_ptr<BTGattHandler>& shared_this, GattServiceList_t& result) noexcept; /** * Discover all characteristics of a service and declaration attributes _only_. @@ -575,7 +575,7 @@ namespace direct_bt { * @return true if successful, otherwise false * @see initClientGatt() */ - bool discoverCompletePrimaryServices(std::shared_ptr<BTGattHandler> shared_this) noexcept; + bool discoverCompletePrimaryServices(const std::shared_ptr<BTGattHandler>& shared_this) noexcept; public: /** @@ -639,7 +639,7 @@ namespace direct_bt { * Returns nullptr if not found. * </p> */ - BTGattCharRef findCharacterisicsByValueHandle(const BTGattServiceRef service, const uint16_t charValueHandle) noexcept; + BTGattCharRef findCharacterisicsByValueHandle(const BTGattServiceRef& service, const uint16_t charValueHandle) noexcept; /** * Initialize the connection and internal data set for GATT client operations: @@ -655,7 +655,7 @@ namespace direct_bt { * @see clientMTUExchange() * @see discoverCompletePrimaryServices() */ - bool initClientGatt(std::shared_ptr<BTGattHandler> shared_this, bool& already_init) noexcept; + bool initClientGatt(const std::shared_ptr<BTGattHandler>& shared_this, bool& already_init) noexcept; /** * Returns a reference of the internal kept BTGattService list. diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp index b206e4c0..e683f821 100644 --- a/api/direct_bt/BTManager.hpp +++ b/api/direct_bt/BTManager.hpp @@ -208,6 +208,8 @@ namespace direct_bt { ClientMaxMTU = 512 }; + typedef jau::nsize_t size_type; + private: friend BTAdapter; @@ -244,7 +246,6 @@ namespace direct_bt { ChangedAdapterSetCallbackList mgmtChangedAdapterSetCallbackList; - typedef jau::nsize_t size_type; typedef jau::cow_darray<std::shared_ptr<BTAdapter>, size_type> adapters_t; adapters_t adapters; diff --git a/api/direct_bt/BTSecurityRegistry.hpp b/api/direct_bt/BTSecurityRegistry.hpp index 124263ca..12375ac0 100644 --- a/api/direct_bt/BTSecurityRegistry.hpp +++ b/api/direct_bt/BTSecurityRegistry.hpp @@ -60,10 +60,10 @@ namespace direct_bt { SMPIOCapability io_cap_auto { SMPIOCapability::UNSET }; int passkey = NO_PASSKEY; - Entry(EUI48Sub addrSub_) - : addrSub(std::move(addrSub_)), nameSub() {} + Entry(const EUI48Sub& addrSub_) + : addrSub(addrSub_), nameSub() {} - Entry(std::string nameSub_) + Entry(std::string nameSub_) : addrSub(EUI48Sub::ALL_DEVICE), nameSub(std::move(nameSub_)) {} constexpr bool isSecLevelOrIOCapSet() const noexcept { diff --git a/api/direct_bt/BTTypes0.hpp b/api/direct_bt/BTTypes0.hpp index 1e6374c2..e82c6fda 100644 --- a/api/direct_bt/BTTypes0.hpp +++ b/api/direct_bt/BTTypes0.hpp @@ -52,7 +52,7 @@ namespace direct_bt { class BTException : public jau::RuntimeException { public: - BTException(std::string const m, const char* file, int line) noexcept + BTException(std::string const& m, const char* file, int line) noexcept : RuntimeException("BTException", m, file, line) {} BTException(const char *m, const char* file, int line) noexcept diff --git a/api/direct_bt/BTTypes1.hpp b/api/direct_bt/BTTypes1.hpp index a078e39d..a47eba30 100644 --- a/api/direct_bt/BTTypes1.hpp +++ b/api/direct_bt/BTTypes1.hpp @@ -117,8 +117,8 @@ namespace direct_bt { std::string short_name; protected: - void setName(const std::string v) noexcept { name = v; } - void setShortName(const std::string v) noexcept { short_name = v; } + void setName(std::string v) noexcept { name = std::move(v); } + void setShortName(std::string v) noexcept { short_name = std::move(v); } public: NameAndShortName() noexcept @@ -247,10 +247,10 @@ namespace direct_bt { return *this; } AdapterInfo(AdapterInfo&& o) noexcept - : dev_id(std::move(o.dev_id)), addressAndType(std::move(o.addressAndType)), version(std::move(o.version)), - manufacturer(std::move(o.manufacturer)), - supported_setting(std::move(o.supported_setting)), - current_setting(o.current_setting.load()), dev_class(std::move(o.dev_class)), + : dev_id(o.dev_id), addressAndType(o.addressAndType), version(o.version), + manufacturer(o.manufacturer), + supported_setting(o.supported_setting), + current_setting(o.current_setting.load()), dev_class(o.dev_class), name(std::move(o.name)), short_name(std::move(o.short_name)) { } AdapterInfo& operator=(AdapterInfo &&o) noexcept = delete; @@ -270,8 +270,8 @@ namespace direct_bt { current_setting = current_setting_; } void setDevClass(const uint32_t v) noexcept { dev_class = v; } - void setName(const std::string v) noexcept { name = v; } - void setShortName(const std::string v) noexcept { short_name = v; } + void setName(std::string v) noexcept { name = std::move(v); } + void setShortName(std::string v) noexcept { short_name = std::move(v); } constexpr const AdapterSetting& get_supportedSetting() const noexcept { return supported_setting; } diff --git a/api/direct_bt/DBGattServer.hpp b/api/direct_bt/DBGattServer.hpp index 0e56f32a..36463e88 100644 --- a/api/direct_bt/DBGattServer.hpp +++ b/api/direct_bt/DBGattServer.hpp @@ -192,9 +192,9 @@ namespace direct_bt { * @param o POctet source to be taken over */ DBGattDesc(DBGattDesc &&o) noexcept - : handle(std::move(o.handle)), type(std::move(o.type)), + : handle(o.handle), type(std::move(o.type)), value(std::move(o.value)), - variable_length(std::move(o.variable_length)) + variable_length(o.variable_length) { JAU_TRACE_DBGATT_PRINT("DBGattDesc ctor-move0: %p -> %p", &o, this); } @@ -426,14 +426,14 @@ namespace direct_bt { * @param o POctet source to be taken over */ DBGattChar(DBGattChar &&o) noexcept - : handle(std::move(o.handle)), end_handle(std::move(o.end_handle)), - value_handle(std::move(o.value_handle)), value_type(std::move(o.value_type)), - properties(std::move(o.properties)), + : handle(o.handle), end_handle(o.end_handle), + value_handle(o.value_handle), value_type(std::move(o.value_type)), + properties(o.properties), descriptors(std::move(o.descriptors)), value(std::move(o.value)), - variable_length(std::move(o.variable_length)), - clientCharConfigIndex(std::move(o.clientCharConfigIndex)), - userDescriptionIndex(std::move(o.userDescriptionIndex)) + variable_length(o.variable_length), + clientCharConfigIndex(o.clientCharConfigIndex), + userDescriptionIndex(o.userDescriptionIndex) { JAU_TRACE_DBGATT_PRINT("DBGattChar: ctor-move0: %p -> %p", &o, this); } @@ -976,8 +976,8 @@ namespace direct_bt { return c; } - bool addListener(ListenerRef l); - bool removeListener(ListenerRef l); + bool addListener(const ListenerRef& l); + bool removeListener(const ListenerRef& l); ListenerList_t& listener() { return listenerList; } std::string toFullString() { diff --git a/api/direct_bt/HCIComm.hpp b/api/direct_bt/HCIComm.hpp index 6eb8d97c..d762efab 100644 --- a/api/direct_bt/HCIComm.hpp +++ b/api/direct_bt/HCIComm.hpp @@ -91,7 +91,7 @@ namespace direct_bt { bool is_open() const noexcept { return 0 <= socket_descriptor; } /** The external `is interrupted` callback is used until close(), thereafter it is removed. */ - void set_interrupted_query(get_boolean_callback_t is_interrupted_cb) { is_interrupted_extern = is_interrupted_cb; } + void set_interrupted_query(get_boolean_callback_t is_interrupted_cb) { is_interrupted_extern = std::move(is_interrupted_cb); } /** Returns true if interrupted by internal or external cause, hence shall stop connecting and reading. */ bool interrupted() const noexcept { return interrupted_intern || ( !is_interrupted_extern.is_null() && is_interrupted_extern(0/*dummy*/) ); } diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp index 51a66d35..e2521aad 100644 --- a/api/direct_bt/HCIHandler.hpp +++ b/api/direct_bt/HCIHandler.hpp @@ -316,7 +316,7 @@ namespace direct_bt { } HCIConnectionRef findTrackerConnection(const uint16_t handle) noexcept; - HCIConnectionRef removeTrackerConnection(const HCIConnectionRef conn) noexcept; + HCIConnectionRef removeTrackerConnection(const HCIConnectionRef& conn) noexcept; size_type countPendingTrackerConnections() noexcept; size_type getTrackerConnectionCount() noexcept; @@ -485,7 +485,7 @@ namespace direct_bt { * * @return HCIStatusCode */ - HCIStatusCode resetAdapter(PostShutdownFunc user_post_shutdown); + HCIStatusCode resetAdapter(const PostShutdownFunc& user_post_shutdown); /** * HCI Reset Command diff --git a/api/direct_bt/HCITypes.hpp b/api/direct_bt/HCITypes.hpp index b460a177..52eb936e 100644 --- a/api/direct_bt/HCITypes.hpp +++ b/api/direct_bt/HCITypes.hpp @@ -59,22 +59,22 @@ namespace direct_bt { class HCIException : public jau::RuntimeException { protected: - HCIException(std::string const type, std::string const m, const char* file, int line) noexcept - : RuntimeException(type, m, file, line) {} + HCIException(std::string type, std::string const& m, const char* file, int line) noexcept + : RuntimeException(std::move(type), m, file, line) {} public: - HCIException(std::string const m, const char* file, int line) noexcept + HCIException(std::string const& m, const char* file, int line) noexcept : RuntimeException("HCIException", m, file, line) {} }; class HCIPacketException : public HCIException { public: - HCIPacketException(std::string const m, const char* file, int line) noexcept + HCIPacketException(std::string const& m, const char* file, int line) noexcept : HCIException("HCIPacketException", m, file, line) {} }; class HCIOpcodeException : public HCIException { public: - HCIOpcodeException(std::string const m, const char* file, int line) noexcept + HCIOpcodeException(std::string const& m, const char* file, int line) noexcept : HCIException("HCIOpcodeException", m, file, line) {} }; diff --git a/api/direct_bt/L2CAPComm.hpp b/api/direct_bt/L2CAPComm.hpp index 2502042e..a0f3576d 100644 --- a/api/direct_bt/L2CAPComm.hpp +++ b/api/direct_bt/L2CAPComm.hpp @@ -173,7 +173,7 @@ namespace direct_bt { bool is_open() const noexcept { return is_open_; } /** The external `is interrupted` callback is used until close(), thereafter it is removed. */ - void set_interrupted_query(get_boolean_callback_t is_interrupted_cb) noexcept { is_interrupted_extern = is_interrupted_cb; } + void set_interrupted_query(get_boolean_callback_t is_interrupted_cb) noexcept { is_interrupted_extern = std::move(is_interrupted_cb); } /** Returns true if interrupted by internal or external cause, hence shall stop connecting and reading. */ bool interrupted() const noexcept { return interrupted_int() || interrupted_ext(); } diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp index 45654301..9a49841a 100644 --- a/api/direct_bt/MgmtTypes.hpp +++ b/api/direct_bt/MgmtTypes.hpp @@ -55,17 +55,17 @@ namespace direct_bt { class MgmtException : public jau::RuntimeException { protected: - MgmtException(std::string const type, std::string const m, const char* file, int line) noexcept - : RuntimeException(type, m, file, line) {} + MgmtException(std::string type, std::string const& m, const char* file, int line) noexcept + : RuntimeException(std::move(type), m, file, line) {} public: - MgmtException(std::string const m, const char* file, int line) noexcept + MgmtException(std::string const& m, const char* file, int line) noexcept : RuntimeException("MgmtException", m, file, line) {} }; class MgmtOpcodeException : public MgmtException { public: - MgmtOpcodeException(std::string const m, const char* file, int line) noexcept + MgmtOpcodeException(std::string const& m, const char* file, int line) noexcept : MgmtException("MgmtOpcodeException", m, file, line) {} }; diff --git a/api/direct_bt/SMPTypes.hpp b/api/direct_bt/SMPTypes.hpp index 767ebe62..af22976d 100644 --- a/api/direct_bt/SMPTypes.hpp +++ b/api/direct_bt/SMPTypes.hpp @@ -57,28 +57,28 @@ namespace direct_bt { class SMPException : public jau::RuntimeException { protected: - SMPException(std::string const type, std::string const m, const char* file, int line) noexcept - : RuntimeException(type, m, file, line) {} + SMPException(std::string type, std::string const& m, const char* file, int line) noexcept + : RuntimeException(std::move(type), m, file, line) {} public: - SMPException(std::string const m, const char* file, int line) noexcept + SMPException(std::string const& m, const char* file, int line) noexcept : RuntimeException("HCIException", m, file, line) {} }; class SMPPacketException : public SMPException { public: - SMPPacketException(std::string const m, const char* file, int line) noexcept + SMPPacketException(std::string const& m, const char* file, int line) noexcept : SMPException("SMPPacketException", m, file, line) {} }; class SMPOpcodeException : public SMPException { public: - SMPOpcodeException(std::string const m, const char* file, int line) noexcept + SMPOpcodeException(std::string const& m, const char* file, int line) noexcept : SMPException("SMPOpcodeException", m, file, line) {} }; class SMPValueException : public SMPException { public: - SMPValueException(std::string const m, const char* file, int line) noexcept + SMPValueException(std::string const& m, const char* file, int line) noexcept : SMPException("SMPValueException", m, file, line) {} }; diff --git a/api/direct_bt/ieee11073/DataTypes.hpp b/api/direct_bt/ieee11073/DataTypes.hpp index a64acf4e..e976cfe9 100644 --- a/api/direct_bt/ieee11073/DataTypes.hpp +++ b/api/direct_bt/ieee11073/DataTypes.hpp @@ -50,13 +50,17 @@ namespace ieee11073 { class RuntimeException : public std::exception { protected: - RuntimeException(std::string const type, std::string const m, const char* file, int line) noexcept - : msg(std::string(type).append(" @ ").append(file).append(":").append(std::to_string(line)).append(": ").append(m)) { } + std::string msg; + + RuntimeException(std::string type, std::string const& m, const char* file, int line) noexcept + : msg( std::move(type) ) + { + msg.append(" @ ").append(file).append(":").append(std::to_string(line)).append(": ").append(m); + } public: - const std::string msg; - RuntimeException(std::string const m, const char* file, int line) noexcept + RuntimeException(std::string const& m, const char* file, int line) noexcept : RuntimeException("RuntimeException", m, file, line) {} ~RuntimeException() noexcept override = default; |