Skip to content

Commit

Permalink
Fix compiler warnings (#79)
Browse files Browse the repository at this point in the history
* fix: for loop iterator comparison

use the same type for the iterator as the value compared to
.size() returns std::size_t

* fix: type qualifiers ignored on function return type

see https://stackoverflow.com/q/60222874
  • Loading branch information
EdJoPaTo authored Feb 8, 2021
1 parent 431af99 commit 97d7794
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/EspMQTTClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ bool EspMQTTClient::subscribe(const String &topic, MessageReceivedCallback messa
{
// Add the record to the subscription list only if it does not exists.
bool found = false;
for (byte i = 0; i < _topicSubscriptionList.size() && !found; i++)
for (std::size_t i = 0; i < _topicSubscriptionList.size() && !found; i++)
found = _topicSubscriptionList[i].topic.equals(topic);

if(!found)
Expand Down Expand Up @@ -469,7 +469,7 @@ bool EspMQTTClient::unsubscribe(const String &topic)
return false;
}

for (int i = 0; i < _topicSubscriptionList.size(); i++)
for (std::size_t i = 0; i < _topicSubscriptionList.size(); i++)
{
if (_topicSubscriptionList[i].topic.equals(topic))
{
Expand Down Expand Up @@ -595,7 +595,7 @@ void EspMQTTClient::processDelayedExecutionRequests()
{
unsigned long currentMillis = millis();

for(int i = 0 ; i < _delayedExecutionList.size() ; i++)
for (std::size_t i = 0 ; i < _delayedExecutionList.size() ; i++)
{
if (_delayedExecutionList[i].targetMillis <= currentMillis)
{
Expand Down Expand Up @@ -672,7 +672,7 @@ void EspMQTTClient::mqttMessageReceivedCallback(char* topic, byte* payload, unsi
Serial.printf("MQTT >> [%s] %s\n", topic, payloadStr.c_str());

// Send the message to subscribers
for (byte i = 0 ; i < _topicSubscriptionList.size() ; i++)
for (std::size_t i = 0 ; i < _topicSubscriptionList.size() ; i++)
{
if (mqttTopicMatch(_topicSubscriptionList[i].topic, String(topic)))
{
Expand Down
2 changes: 1 addition & 1 deletion src/EspMQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class EspMQTTClient

inline const char* getMqttClientName() { return _mqttClientName; };
inline const char* getMqttServerIp() { return _mqttServerIp; };
inline const short getMqttServerPort() { return _mqttServerPort; };
inline short getMqttServerPort() { return _mqttServerPort; };

// Default to onConnectionEstablished, you might want to override this for special cases like two MQTT connections in the same sketch
inline void setOnConnectionEstablishedCallback(ConnectionEstablishedCallback callback) { _connectionEstablishedCallback = callback; };
Expand Down

0 comments on commit 97d7794

Please sign in to comment.