From cb0cf75c9958f37378e730eaf923b82ba5d193a8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:32:32 +0200 Subject: [PATCH] [MQTT] Fixes from cppcheck scan --- src/protocols/MQTT/MQTT.cpp | 3 --- src/protocols/MQTT/MQTT.h | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/protocols/MQTT/MQTT.cpp b/src/protocols/MQTT/MQTT.cpp index cc561157..cb62321c 100644 --- a/src/protocols/MQTT/MQTT.cpp +++ b/src/protocols/MQTT/MQTT.cpp @@ -96,7 +96,6 @@ int16_t MQTTClient::connect(const char* host, const char* clientId, const char* packet[pos++] = (passwordLen & 0xFF00) >> 8;; packet[pos++] = passwordLen & 0x00FF; memcpy(packet + pos, password, passwordLen); - pos += passwordLen; } // create TCP connection @@ -198,7 +197,6 @@ int16_t MQTTClient::publish(const char* topic, const char* message) { // payload // message memcpy(packet + pos, message, messageLen); - pos += messageLen; // send MQTT packet int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength); @@ -314,7 +312,6 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) { packet[pos++] = (topicFilterLen & 0xFF00) >> 8;; packet[pos++] = topicFilterLen & 0x00FF; memcpy(packet + pos, topicFilter, topicFilterLen); - pos += topicFilterLen; // send MQTT packet int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength); diff --git a/src/protocols/MQTT/MQTT.h b/src/protocols/MQTT/MQTT.h index efc40d3a..e6b0adbe 100644 --- a/src/protocols/MQTT/MQTT.h +++ b/src/protocols/MQTT/MQTT.h @@ -39,7 +39,7 @@ class MQTTClient { \param tl Pointer to the wireless module providing TransportLayer communication. */ - MQTTClient(TransportLayer* tl, uint16_t port = 1883); + explicit MQTTClient(TransportLayer* tl, uint16_t port = 1883); // basic methods @@ -135,8 +135,8 @@ class MQTTClient { uint16_t _port; uint16_t _packetId; - size_t encodeLength(uint32_t len, uint8_t* encoded); - uint32_t decodeLength(uint8_t* encoded); + static size_t encodeLength(uint32_t len, uint8_t* encoded); + static uint32_t decodeLength(uint8_t* encoded); }; #endif