summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-10-20 05:49:25 +0200
committerSven Gothel <[email protected]>2020-10-20 05:49:25 +0200
commit16b45949632960c9e4ccfc10b44f3cd4433cf78f (patch)
treeab0a77c1a8eef58f709062747cbbec85a734dd47 /src
parent1f6e924fe05ed45bfa4d0d901af2c4df6c1abab5 (diff)
Use -Wshadow: Shadowing (or local scope override) often causing sloppy bugs, avoid 1/2 (direct_bt)
Another shadow bug fixed: UUID string ctor in UUID.cpp
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/BTTypes.cpp12
-rw-r--r--src/direct_bt/DBTAdapter.cpp24
-rw-r--r--src/direct_bt/GATTHandler.cpp4
-rw-r--r--src/direct_bt/HCIHandler.cpp8
-rw-r--r--src/direct_bt/L2CAPComm.cpp16
-rw-r--r--src/direct_bt/UUID.cpp1
6 files changed, 32 insertions, 33 deletions
diff --git a/src/direct_bt/BTTypes.cpp b/src/direct_bt/BTTypes.cpp
index 0b91d261..88b50032 100644
--- a/src/direct_bt/BTTypes.cpp
+++ b/src/direct_bt/BTTypes.cpp
@@ -370,12 +370,12 @@ static std::string bt_compidtostr(const uint16_t companyid) noexcept {
return std::to_string(companyid);
}
-ManufactureSpecificData::ManufactureSpecificData(uint16_t const company) noexcept
-: company(company), companyName(std::string(bt_compidtostr(company))), data(/* intentional zero sized */) {
+ManufactureSpecificData::ManufactureSpecificData(uint16_t const company_) noexcept
+: company(company_), companyName(std::string(bt_compidtostr(company_))), data(/* intentional zero sized */) {
}
-ManufactureSpecificData::ManufactureSpecificData(uint16_t const company, uint8_t const * const data, int const data_len) noexcept
-: company(company), companyName(std::string(bt_compidtostr(company))), data(data, data_len) {
+ManufactureSpecificData::ManufactureSpecificData(uint16_t const company_, uint8_t const * const data_, size_t const data_len) noexcept
+: company(company_), companyName(std::string(bt_compidtostr(company_))), data(data_, data_len) {
}
std::string ManufactureSpecificData::toString() const noexcept {
@@ -487,8 +487,8 @@ void EInfoReport::setManufactureSpecificData(uint16_t const company, uint8_t con
set(EIRDataType::MANUF_DATA);
}
-void EInfoReport::setDeviceID(const uint16_t source, const uint16_t vendor, const uint16_t product, const uint16_t version) noexcept {
- did_source = source;
+void EInfoReport::setDeviceID(const uint16_t source_, const uint16_t vendor, const uint16_t product, const uint16_t version) noexcept {
+ did_source = source_;
did_vendor = vendor;
did_product = product;
did_version = version;
diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/DBTAdapter.cpp
index 154a7366..b54ac3eb 100644
--- a/src/direct_bt/DBTAdapter.cpp
+++ b/src/direct_bt/DBTAdapter.cpp
@@ -718,10 +718,10 @@ bool DBTAdapter::mgmtEvDeviceDiscoveringMgmt(std::shared_ptr<MgmtEvent> e) noexc
jau::for_each_cow(statusListenerList, [&](std::shared_ptr<AdapterStatusListener> &l) {
try {
l->discoveringChanged(*this, enabled, keepDiscoveringAlive, event.getTimestamp());
- } catch (std::exception &e) {
+ } catch (std::exception &except) {
ERR_PRINT("DBTAdapter::EventCB:DeviceDiscovering-CBs %d/%zd: %s of %s: Caught exception %s",
i+1, statusListenerList.size(),
- l->toString().c_str(), toString().c_str(), e.what());
+ l->toString().c_str(), toString().c_str(), except.what());
}
i++;
});
@@ -897,10 +897,10 @@ bool DBTAdapter::mgmtEvDeviceConnectedHCI(std::shared_ptr<MgmtEvent> e) noexcept
l->deviceConnected(device, event.getHCIHandle(), event.getTimestamp());
}
}
- } catch (std::exception &e) {
+ } catch (std::exception &except) {
ERR_PRINT("DBTAdapter::EventHCI:DeviceConnected-CBs %d/%zd: %s of %s: Caught exception %s",
i+1, statusListenerList.size(),
- l->toString().c_str(), device->toString().c_str(), e.what());
+ l->toString().c_str(), device->toString().c_str(), except.what());
}
i++;
});
@@ -927,10 +927,10 @@ bool DBTAdapter::mgmtEvConnectFailedHCI(std::shared_ptr<MgmtEvent> e) noexcept {
if( l->matchDevice(*device) ) {
l->deviceDisconnected(device, event.getHCIStatus(), handle, event.getTimestamp());
}
- } catch (std::exception &e) {
+ } catch (std::exception &except) {
ERR_PRINT("DBTAdapter::EventHCI:DeviceDisconnected-CBs %d/%zd: %s of %s: Caught exception %s",
i+1, statusListenerList.size(),
- l->toString().c_str(), device->toString().c_str(), e.what());
+ l->toString().c_str(), device->toString().c_str(), except.what());
}
i++;
});
@@ -965,10 +965,10 @@ bool DBTAdapter::mgmtEvDeviceDisconnectedHCI(std::shared_ptr<MgmtEvent> e) noexc
if( l->matchDevice(*device) ) {
l->deviceDisconnected(device, event.getHCIReason(), event.getHCIHandle(), event.getTimestamp());
}
- } catch (std::exception &e) {
+ } catch (std::exception &except) {
ERR_PRINT("DBTAdapter::EventHCI:DeviceDisconnected-CBs %d/%zd: %s of %s: Caught exception %s",
i+1, statusListenerList.size(),
- l->toString().c_str(), device->toString().c_str(), e.what());
+ l->toString().c_str(), device->toString().c_str(), except.what());
}
i++;
});
@@ -1038,10 +1038,10 @@ bool DBTAdapter::mgmtEvDeviceFoundHCI(std::shared_ptr<MgmtEvent> e) noexcept {
if( l->matchDevice(*dev) ) {
l->deviceFound(dev, eir->getTimestamp());
}
- } catch (std::exception &e) {
+ } catch (std::exception &except) {
ERR_PRINT("DBTAdapter::EventCB:DeviceFound: %d/%zd: %s of %s: Caught exception %s",
i+1, statusListenerList.size(),
- l->toString().c_str(), dev->toString().c_str(), e.what());
+ l->toString().c_str(), dev->toString().c_str(), except.what());
}
i++;
});
@@ -1066,10 +1066,10 @@ bool DBTAdapter::mgmtEvDeviceFoundHCI(std::shared_ptr<MgmtEvent> e) noexcept {
if( l->matchDevice(*dev) ) {
l->deviceFound(dev, eir->getTimestamp());
}
- } catch (std::exception &e) {
+ } catch (std::exception &except) {
ERR_PRINT("DBTAdapter::EventCB:DeviceFound-CBs %d/%zd: %s of %s: Caught exception %s",
i+1, statusListenerList.size(),
- l->toString().c_str(), dev->toString().c_str(), e.what());
+ l->toString().c_str(), dev->toString().c_str(), except.what());
}
i++;
});
diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/GATTHandler.cpp
index d881ca9f..bbc303ea 100644
--- a/src/direct_bt/GATTHandler.cpp
+++ b/src/direct_bt/GATTHandler.cpp
@@ -475,8 +475,8 @@ GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_
return findCharacterisicsByValueHandle(charValueHandle, services);
}
-GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle, std::vector<GATTServiceRef> &services) noexcept {
- for(auto it = services.begin(); it != services.end(); it++) {
+GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle, std::vector<GATTServiceRef> &services_) noexcept {
+ for(auto it = services_.begin(); it != services_.end(); it++) {
GATTCharacteristicRef decl = findCharacterisicsByValueHandle(charValueHandle, *it);
if( nullptr != decl ) {
return decl;
diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp
index 9bdae951..2fe1bb05 100644
--- a/src/direct_bt/HCIHandler.cpp
+++ b/src/direct_bt/HCIHandler.cpp
@@ -432,15 +432,15 @@ exit:
return ev;
}
-HCIHandler::HCIHandler(const uint16_t dev_id, const BTMode btMode) noexcept
+HCIHandler::HCIHandler(const uint16_t dev_id_, const BTMode btMode_) noexcept
: env(HCIEnv::get()),
- dev_id(dev_id),
+ dev_id(dev_id_),
rbuffer(HCI_MAX_MTU),
- comm(dev_id, HCI_CHANNEL_RAW),
+ comm(dev_id_, HCI_CHANNEL_RAW),
hciEventRing(env.HCI_EVT_RING_CAPACITY), hciReaderShallStop(false),
hciReaderThreadId(0), hciReaderRunning(false),
allowClose( comm.isOpen() ),
- btMode(btMode)
+ btMode(btMode_)
{
WORDY_PRINT("HCIHandler.ctor: pid %d", HCIHandler::pidSelf);
if( !allowClose ) {
diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp
index 6e2514d1..ca83109e 100644
--- a/src/direct_bt/L2CAPComm.cpp
+++ b/src/direct_bt/L2CAPComm.cpp
@@ -105,10 +105,10 @@ int L2CAPComm::l2cap_close_dev(int dd)
// *************************************************
// *************************************************
-L2CAPComm::L2CAPComm(std::shared_ptr<DBTDevice> device, const uint16_t psm, const uint16_t cid)
+L2CAPComm::L2CAPComm(std::shared_ptr<DBTDevice> device_, const uint16_t psm_, const uint16_t cid_)
: env(L2CAPEnv::get()),
- device(device), deviceString(device->getAddressString()), psm(psm), cid(cid),
- socket_descriptor( l2cap_open_dev(device->getAdapter().getAddress(), psm, cid, true /* pubaddrAdptr */) ),
+ device(device_), deviceString(device_->getAddressString()), psm(psm_), cid(cid_),
+ socket_descriptor( l2cap_open_dev(device_->getAdapter().getAddress(), psm_, cid_, true /* pubaddrAdptr */) ),
is_connected(true), has_ioerror(false), interrupt_flag(false), tid_connect(0), tid_read(0)
{
/** BT Core Spec v5.2: Vol 3, Part A: L2CAP_CONNECTION_REQ */
@@ -117,7 +117,7 @@ L2CAPComm::L2CAPComm(std::shared_ptr<DBTDevice> device, const uint16_t psm, cons
int to_retry_count=0; // ETIMEDOUT retry count
DBG_PRINT("L2CAPComm::ctor: Start Connect: %s, dd %d, %s, psm %u, cid %u, pubDevice %d",
- getStateString().c_str(), socket_descriptor.load(), deviceString.c_str(), psm, cid, true);
+ getStateString().c_str(), socket_descriptor.load(), deviceString.c_str(), psm_, cid_, true);
if( 0 > socket_descriptor ) {
goto failure; // open failed
@@ -127,10 +127,10 @@ L2CAPComm::L2CAPComm(std::shared_ptr<DBTDevice> device, const uint16_t psm, cons
// actual request to connect to remote device
bzero((void *)&req, sizeof(req));
req.l2_family = AF_BLUETOOTH;
- req.l2_psm = jau::cpu_to_le(psm);
- req.l2_bdaddr = device->getAddress();
- req.l2_cid = jau::cpu_to_le(cid);
- req.l2_bdaddr_type = device->getAddressType();
+ req.l2_psm = jau::cpu_to_le(psm_);
+ req.l2_bdaddr = device_->getAddress();
+ req.l2_cid = jau::cpu_to_le(cid_);
+ req.l2_bdaddr_type = device_->getAddressType();
while( !interrupt_flag ) {
// blocking
diff --git a/src/direct_bt/UUID.cpp b/src/direct_bt/UUID.cpp
index 7252f02f..5b3a744c 100644
--- a/src/direct_bt/UUID.cpp
+++ b/src/direct_bt/UUID.cpp
@@ -176,7 +176,6 @@ uuid128_t::uuid128_t(const std::string str)
std::string msg("UUID128 string not in format '00000000-0000-1000-8000-00805F9B34FB' but "+str);
throw jau::IllegalArgumentException(msg, E_FILE_LINE);
}
- jau::uint128_t value;
// sscanf provided host data type, in which we store the values,
// hence no endian conversion