Use return value in order to return the topic string size as the topic string is...
authorNathael Pajani <nathael.pajani@ed3l.fr>
Sat, 16 Mar 2019 16:30:08 +0000 (17:30 +0100)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:05 +0000 (17:03 +0100)
lib/protocols/mqtt.c

index d0a62d4..6a6cef7 100644 (file)
@@ -309,6 +309,7 @@ int mqtt_pack_publish_packet(const struct mqtt_publish_pkt* pkt, uint8_t* buf, u
  * The function also checks the validity of the packet.
  * All returned pointers within the struct will point to parts of the provided buffer, so the buffer
  * must not be discarded after the call.
+ * if the return value is positive, it is the topic string length.
  */
 int mqtt_unpack_publish_packet(struct mqtt_publish_pkt* pkt, uint8_t* buf, uint32_t size)
 {
@@ -359,7 +360,7 @@ int mqtt_unpack_publish_packet(struct mqtt_publish_pkt* pkt, uint8_t* buf, uint3
        if (pkt->message_size != 0) {
                pkt->application_message = (buf + idx);
        }
-       return 0;
+       return topic_len;
 }
 
 /***************************************************************************** */