From 7dc8f5e7e497c3d8f34b7be3fd9a1e04333226b1 Mon Sep 17 00:00:00 2001 From: eutill <48715304+eutill@users.noreply.github.com> Date: Sun, 29 Mar 2020 23:52:21 +0200 Subject: [PATCH 1/2] Removed all occurences of pgm_read_byte --- Adafruit_MQTT.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 42fcf95..d9b06e9 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -578,7 +578,7 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { p[0] = MQTT_CONN_CLEANSESSION; // set the will flags if needed - if (will_topic && pgm_read_byte(will_topic) != 0) { + if (will_topic && will_topic[0] != '\0') { p[0] |= MQTT_CONN_WILLFLAG; @@ -592,9 +592,9 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { } - if (pgm_read_byte(username) != 0) + if (username[0] != '\0') p[0] |= MQTT_CONN_USERNAMEFLAG; - if (pgm_read_byte(password) != 0) + if (password[0] != '\0') p[0] |= MQTT_CONN_PASSWORDFLAG; p++; @@ -606,7 +606,7 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { if(MQTT_PROTOCOL_LEVEL == 3) { p = stringprint(p, clientid, 23); // Limit client ID to first 23 characters. } else { - if (pgm_read_byte(clientid) != 0) { + if (clientid[0] != '\0') { p = stringprint(p, clientid); } else { p[0] = 0x0; @@ -617,15 +617,15 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { } } - if (will_topic && pgm_read_byte(will_topic) != 0) { + if (will_topic && will_topic[0] != '\0') { p = stringprint(p, will_topic); p = stringprint(p, will_payload); } - if (pgm_read_byte(username) != 0) { + if (username[0] != '\0') { p = stringprint(p, username); } - if (pgm_read_byte(password) != 0) { + if (password[0] != '\0') { p = stringprint(p, password); } From fc93f7972e04ed88b3bab2fb8edf9bc5561240d3 Mon Sep 17 00:00:00 2001 From: eutill <48715304+eutill@users.noreply.github.com> Date: Fri, 9 Apr 2021 11:37:04 +0200 Subject: [PATCH 2/2] Changed null-termination check to usual form --- Adafruit_MQTT.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index d9b06e9..85c020c 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -578,7 +578,7 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { p[0] = MQTT_CONN_CLEANSESSION; // set the will flags if needed - if (will_topic && will_topic[0] != '\0') { + if (will_topic && will_topic[0] != 0) { p[0] |= MQTT_CONN_WILLFLAG; @@ -592,9 +592,9 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { } - if (username[0] != '\0') + if (username[0] != 0) p[0] |= MQTT_CONN_USERNAMEFLAG; - if (password[0] != '\0') + if (password[0] != 0) p[0] |= MQTT_CONN_PASSWORDFLAG; p++; @@ -606,7 +606,7 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { if(MQTT_PROTOCOL_LEVEL == 3) { p = stringprint(p, clientid, 23); // Limit client ID to first 23 characters. } else { - if (clientid[0] != '\0') { + if (clientid[0] != 0) { p = stringprint(p, clientid); } else { p[0] = 0x0; @@ -617,15 +617,15 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { } } - if (will_topic && will_topic[0] != '\0') { + if (will_topic && will_topic[0] != 0) { p = stringprint(p, will_topic); p = stringprint(p, will_payload); } - if (username[0] != '\0') { + if (username[0] != 0) { p = stringprint(p, username); } - if (password[0] != '\0') { + if (password[0] != 0) { p = stringprint(p, password); }