Skip to content

Commit

Permalink
Merge pull request #4 from arduino-hmueller01/fix-Wsign-compare
Browse files Browse the repository at this point in the history
fix compiler warning
  • Loading branch information
imbeacon authored Sep 9, 2024
2 parents 7b9768a + c7e3e47 commit 97cc3a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/PubSubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,13 @@ boolean PubSubClient::publish(const char* topic, const char* payload, boolean re
return publish(topic,(const uint8_t*)payload, payload ? strnlen(payload, this->bufferSize) : 0,retained);
}

boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength) {
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, size_t plength) {
return publish(topic, payload, plength, false);
}

boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) {
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, size_t plength, boolean retained) {
if (connected()) {
if (this->bufferSize < MQTT_MAX_HEADER_SIZE + 2+strnlen(topic, this->bufferSize) + plength) {
if (this->bufferSize < MQTT_MAX_HEADER_SIZE + 2 + strnlen(topic, this->bufferSize) + plength) {
// Too long
return false;
}
Expand Down Expand Up @@ -507,16 +507,16 @@ boolean PubSubClient::publish_P(const char* topic, const char* payload, boolean
return publish_P(topic, (const uint8_t*)payload, payload ? strnlen_P(payload, this->bufferSize) : 0, retained);
}

boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) {
boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, size_t plength, boolean retained) {
uint8_t llen = 0;
uint8_t digit;
unsigned int rc = 0;
uint16_t tlen;
unsigned int pos = 0;
unsigned int i;
uint8_t header;
unsigned int len;
int expectedLength;
size_t len;
size_t expectedLength;

if (!connected()) {
return false;
Expand Down Expand Up @@ -555,7 +555,7 @@ boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsig
return (rc == expectedLength);
}

boolean PubSubClient::beginPublish(const char* topic, unsigned int plength, boolean retained) {
boolean PubSubClient::beginPublish(const char* topic, size_t plength, boolean retained) {
if (connected()) {
// Send the header and variable length field
uint16_t length = MQTT_MAX_HEADER_SIZE;
Expand Down
14 changes: 7 additions & 7 deletions src/PubSubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
# ifdef __has_include
# if __has_include(<functional>)
# include <functional>
# define MQTT_CALLBACK_SIGNATURE std::function<void(char*, uint8_t*, unsigned int)> callback
# define MQTT_CALLBACK_SIGNATURE std::function<void(char*, uint8_t*, size_t)> callback
# else
# define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, unsigned int)
# define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, size_t)
# endif
# else
# define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, unsigned int)
# define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, size_t)
# endif

#define CHECK_STRING_LENGTH(l,s) if (l+2+strnlen(s, this->bufferSize) > this->bufferSize) {_client->stop();return false;}
Expand Down Expand Up @@ -154,10 +154,10 @@ class PubSubClient : public Print {
void disconnect();
boolean publish(const char* topic, const char* payload);
boolean publish(const char* topic, const char* payload, boolean retained);
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
boolean publish(const char* topic, const uint8_t * payload, size_t plength);
boolean publish(const char* topic, const uint8_t * payload, size_t plength, boolean retained);
boolean publish_P(const char* topic, const char* payload, boolean retained);
boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
boolean publish_P(const char* topic, const uint8_t * payload, size_t plength, boolean retained);
// Start to publish a message.
// This API:
// beginPublish(...)
Expand All @@ -166,7 +166,7 @@ class PubSubClient : public Print {
// Allows for arbitrarily large payloads to be sent without them having to be copied into
// a new buffer and held in memory at one time
// Returns 1 if the message was started successfully, 0 if there was an error
boolean beginPublish(const char* topic, unsigned int plength, boolean retained);
boolean beginPublish(const char* topic, size_t plength, boolean retained);
// Finish off this publish message (started with beginPublish)
// Returns 1 if the packet was sent successfully, 0 if there was an error
int endPublish();
Expand Down

0 comments on commit 97cc3a5

Please sign in to comment.