Skip to content

Commit 4506c7f

Browse files
committed
more warning fixes
1 parent 7be58ce commit 4506c7f

14 files changed

+53
-10
lines changed

libraries/BLE/src/BLEAdvertisedDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ BLEUUID BLEAdvertisedDevice::getServiceUUID(int i) {
167167
* @return Return true if service is advertised
168168
*/
169169
bool BLEAdvertisedDevice::isAdvertisingService(BLEUUID uuid){
170-
for (int i = 0; i < m_serviceUUIDs.size(); i++) {
170+
for (std::size_t i = 0; i < m_serviceUUIDs.size(); i++) {
171171
if (m_serviceUUIDs[i].equals(uuid)) return true;
172172
}
173173
return false;
@@ -533,7 +533,7 @@ std::string BLEAdvertisedDevice::toString() {
533533
free(pHex);
534534
}
535535
if (haveServiceUUID()) {
536-
for (int i=0; i < m_serviceUUIDs.size(); i++) {
536+
for (std::size_t i=0; i < m_serviceUUIDs.size(); i++) {
537537
res += ", serviceUUID: " + getServiceUUID(i).toString();
538538
}
539539
}

libraries/BLE/src/BLEAdvertising.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ std::string BLEAdvertisementData::getPayload() {
491491
void BLEAdvertising::handleGAPEvent(
492492
esp_gap_ble_cb_event_t event,
493493
esp_ble_gap_cb_param_t* param) {
494-
494+
(void)param; // unused
495495
log_d("handleGAPEvent [event no: %d]", (int)event);
496496

497497
switch(event) {

libraries/BLE/src/BLECharacteristic.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ void BLECharacteristic::notify(bool is_notification) {
509509
}
510510
for (auto &myPair : getService()->getServer()->getPeerDevices(false)) {
511511
uint16_t _mtu = (myPair.second.mtu);
512-
if (m_value.getValue().length() > _mtu - 3) {
512+
if (m_value.getValue().length() > (std::size_t)(_mtu - 3)) {
513513
log_w("- Truncating to %d bytes (maximum notify size)", _mtu - 3);
514514
}
515515

@@ -759,6 +759,7 @@ BLECharacteristicCallbacks::~BLECharacteristicCallbacks() {}
759759
* @param [in] pCharacteristic The characteristic that is the source of the event.
760760
*/
761761
void BLECharacteristicCallbacks::onRead(BLECharacteristic* pCharacteristic) {
762+
(void)pCharacteristic; // unused
762763
log_d("BLECharacteristicCallbacks", ">> onRead: default");
763764
log_d("BLECharacteristicCallbacks", "<< onRead");
764765
} // onRead
@@ -769,6 +770,7 @@ void BLECharacteristicCallbacks::onRead(BLECharacteristic* pCharacteristic) {
769770
* @param [in] pCharacteristic The characteristic that is the source of the event.
770771
*/
771772
void BLECharacteristicCallbacks::onWrite(BLECharacteristic* pCharacteristic) {
773+
(void)pCharacteristic; // unused
772774
log_d("BLECharacteristicCallbacks", ">> onWrite: default");
773775
log_d("BLECharacteristicCallbacks", "<< onWrite");
774776
} // onWrite
@@ -779,6 +781,7 @@ void BLECharacteristicCallbacks::onWrite(BLECharacteristic* pCharacteristic) {
779781
* @param [in] pCharacteristic The characteristic that is the source of the event.
780782
*/
781783
void BLECharacteristicCallbacks::onNotify(BLECharacteristic* pCharacteristic) {
784+
(void)pCharacteristic; // unused
782785
log_d("BLECharacteristicCallbacks", ">> onNotify: default");
783786
log_d("BLECharacteristicCallbacks", "<< onNotify");
784787
} // onNotify
@@ -791,6 +794,9 @@ void BLECharacteristicCallbacks::onNotify(BLECharacteristic* pCharacteristic) {
791794
* @param [in] code Additional code of underlying errors
792795
*/
793796
void BLECharacteristicCallbacks::onStatus(BLECharacteristic* pCharacteristic, Status s, uint32_t code) {
797+
(void)pCharacteristic; // unused
798+
(void)s; // unused
799+
(void)code; // unused
794800
log_d("BLECharacteristicCallbacks", ">> onStatus: default");
795801
log_d("BLECharacteristicCallbacks", "<< onStatus");
796802
} // onStatus

libraries/BLE/src/BLEDescriptor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ void BLEDescriptor::handleGATTServerEvent(
128128
esp_gatts_cb_event_t event,
129129
esp_gatt_if_t gatts_if,
130130
esp_ble_gatts_cb_param_t* param) {
131+
(void)gatts_if; // unused
131132
switch (event) {
132133
// ESP_GATTS_ADD_CHAR_DESCR_EVT
133134
//
@@ -269,6 +270,7 @@ BLEDescriptorCallbacks::~BLEDescriptorCallbacks() {}
269270
* @param [in] pDescriptor The descriptor that is the source of the event.
270271
*/
271272
void BLEDescriptorCallbacks::onRead(BLEDescriptor* pDescriptor) {
273+
(void)pDescriptor; // unused
272274
log_d("BLEDescriptorCallbacks", ">> onRead: default");
273275
log_d("BLEDescriptorCallbacks", "<< onRead");
274276
} // onRead
@@ -279,6 +281,7 @@ void BLEDescriptorCallbacks::onRead(BLEDescriptor* pDescriptor) {
279281
* @param [in] pDescriptor The descriptor that is the source of the event.
280282
*/
281283
void BLEDescriptorCallbacks::onWrite(BLEDescriptor* pDescriptor) {
284+
(void)pDescriptor; // unused
282285
log_d("BLEDescriptorCallbacks", ">> onWrite: default");
283286
log_d("BLEDescriptorCallbacks", "<< onWrite");
284287
} // onWrite

libraries/BLE/src/BLEDevice.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
*/
77
#include "sdkconfig.h"
88
#if defined(CONFIG_BT_ENABLED)
9+
#pragma GCC diagnostic push
10+
#pragma GCC diagnostic ignored "-Wsign-compare"
911
#include <freertos/FreeRTOS.h>
12+
#pragma GCC diagnostic pop
1013
#include <freertos/event_groups.h>
1114
#include <freertos/task.h>
1215
#include <esp_err.h>
@@ -587,6 +590,7 @@ void BLEDevice::stopAdvertising() {
587590
/* multi connect support */
588591
/* requires a little more work */
589592
std::map<uint16_t, conn_status_t> BLEDevice::getPeerDevices(bool _client) {
593+
(void)_client; // unused
590594
return m_connectedClientsMap;
591595
}
592596

@@ -595,6 +599,7 @@ BLEClient* BLEDevice::getClientByGattIf(uint16_t conn_id) {
595599
}
596600

597601
void BLEDevice::updatePeerDevice(void* peer, bool _client, uint16_t conn_id) {
602+
(void)_client; // may be used depending on definition of 'log_d'
598603
log_d("update conn_id: %d, GATT role: %s", conn_id, _client? "client":"server");
599604
std::map<uint16_t, conn_status_t>::iterator it = m_connectedClientsMap.find(ESP_GATT_IF_NONE);
600605
if (it != m_connectedClientsMap.end()) {
@@ -611,6 +616,7 @@ void BLEDevice::updatePeerDevice(void* peer, bool _client, uint16_t conn_id) {
611616
}
612617

613618
void BLEDevice::addPeerDevice(void* peer, bool _client, uint16_t conn_id) {
619+
(void)_client; // may be used depending on definition of 'log_i'
614620
log_i("add conn_id: %d, GATT role: %s", conn_id, _client? "client":"server");
615621
conn_status_t status = {
616622
.peer_device = peer,
@@ -622,6 +628,7 @@ void BLEDevice::addPeerDevice(void* peer, bool _client, uint16_t conn_id) {
622628
}
623629

624630
void BLEDevice::removePeerDevice(uint16_t conn_id, bool _client) {
631+
(void)_client; // may be used depending on definition of 'log_i'
625632
log_i("remove: %d, GATT role %s", conn_id, _client?"client":"server");
626633
if(m_connectedClientsMap.find(conn_id) != m_connectedClientsMap.end())
627634
m_connectedClientsMap.erase(conn_id);

libraries/BLE/src/BLERemoteCharacteristic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static bool compareGattId(esp_gatt_id_t id1, esp_gatt_id_t id2) {
144144
* @returns N/A
145145
*/
146146
void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t* evtParam) {
147+
(void)gattc_if;
147148
switch(event) {
148149
// ESP_GATTC_NOTIFY_EVT
149150
//

libraries/BLE/src/BLERemoteService.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,12 @@ std::map<uint16_t, BLERemoteCharacteristic*>* BLERemoteService::getCharacteristi
243243
/**
244244
* @brief This function is designed to get characteristics map when we have multiple characteristics with the same UUID
245245
*/
246+
#pragma GCC diagnostic push
247+
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
246248
void BLERemoteService::getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>* pCharacteristicMap) {
247249
pCharacteristicMap = &m_characteristicMapByHandle;
248250
} // Get the characteristics map.
251+
#pragma GCC diagnostic pop
249252

250253
/**
251254
* @brief Get the client associated with this service.

libraries/BLE/src/BLEServer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,23 @@ bool BLEServer::connect(BLEAddress address) {
347347

348348

349349
void BLEServerCallbacks::onConnect(BLEServer* pServer) {
350+
(void)pServer; // unused
350351
log_d("BLEServerCallbacks", ">> onConnect(): Default");
351352
log_d("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
352353
log_d("BLEServerCallbacks", "<< onConnect()");
353354
} // onConnect
354355

355356
void BLEServerCallbacks::onConnect(BLEServer* pServer, esp_ble_gatts_cb_param_t* param) {
357+
(void)pServer; // unused
358+
(void)param; // unused
356359
log_d("BLEServerCallbacks", ">> onConnect(): Default");
357360
log_d("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
358361
log_d("BLEServerCallbacks", "<< onConnect()");
359362
} // onConnect
360363

361364

362365
void BLEServerCallbacks::onDisconnect(BLEServer* pServer) {
366+
(void)pServer; // unused
363367
log_d("BLEServerCallbacks", ">> onDisconnect(): Default");
364368
log_d("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
365369
log_d("BLEServerCallbacks", "<< onDisconnect()");
@@ -377,6 +381,7 @@ void BLEServer::updatePeerMTU(uint16_t conn_id, uint16_t mtu) {
377381
}
378382

379383
std::map<uint16_t, conn_status_t> BLEServer::getPeerDevices(bool _client) {
384+
(void)_client; // unused
380385
return m_connectedServersMap;
381386
}
382387

@@ -386,6 +391,7 @@ uint16_t BLEServer::getPeerMTU(uint16_t conn_id) {
386391
}
387392

388393
void BLEServer::addPeerDevice(void* peer, bool _client, uint16_t conn_id) {
394+
(void)_client; // unused
389395
conn_status_t status = {
390396
.peer_device = peer,
391397
.connected = true,
@@ -396,6 +402,7 @@ void BLEServer::addPeerDevice(void* peer, bool _client, uint16_t conn_id) {
396402
}
397403

398404
void BLEServer::removePeerDevice(uint16_t conn_id, bool _client) {
405+
(void)_client; // unused
399406
m_connectedServersMap.erase(conn_id);
400407
}
401408
/* multi connect support */

libraries/BLE/src/BLEServiceMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ BLEService* BLEServiceMap::getByUUID(const char* uuid) {
2626
* @return The characteristic.
2727
*/
2828
BLEService* BLEServiceMap::getByUUID(BLEUUID uuid, uint8_t inst_id) {
29+
(void)inst_id; // unused
2930
for (auto &myPair : m_uuidMap) {
3031
if (myPair.first->getUUID().equals(uuid)) {
3132
return myPair.first;

libraries/BLE/src/BLEUUID.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ BLEUUID::BLEUUID(std::string value) {
6868
if (value.length() == 4) {
6969
m_uuid.len = ESP_UUID_LEN_16;
7070
m_uuid.uuid.uuid16 = 0;
71-
for(int i=0;i<value.length();){
71+
for(std::size_t i=0;i<value.length();){
7272
uint8_t MSB = value.c_str()[i];
7373
uint8_t LSB = value.c_str()[i+1];
7474

@@ -81,7 +81,7 @@ BLEUUID::BLEUUID(std::string value) {
8181
else if (value.length() == 8) {
8282
m_uuid.len = ESP_UUID_LEN_32;
8383
m_uuid.uuid.uuid32 = 0;
84-
for(int i=0;i<value.length();){
84+
for(std::size_t i=0;i<value.length();){
8585
uint8_t MSB = value.c_str()[i];
8686
uint8_t LSB = value.c_str()[i+1];
8787

@@ -100,7 +100,7 @@ BLEUUID::BLEUUID(std::string value) {
100100
// UUID format.
101101
m_uuid.len = ESP_UUID_LEN_128;
102102
int n = 0;
103-
for(int i=0;i<value.length();){
103+
for(std::size_t i=0;i<value.length();){
104104
if(value.c_str()[i] == '-')
105105
i++;
106106
uint8_t MSB = value.c_str()[i];

0 commit comments

Comments
 (0)