From: Nathael Pajani Date: Sat, 16 Mar 2019 16:30:08 +0000 (+0100) Subject: Use return value in order to return the topic string size as the topic string is... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=39d0c7af506ea7c5703192ec7ffa07bdd6853b26;p=soft%2Flpc122x%2Fcore Use return value in order to return the topic string size as the topic string is not null terminated. --- diff --git a/lib/protocols/mqtt.c b/lib/protocols/mqtt.c index d0a62d4..6a6cef7 100644 --- a/lib/protocols/mqtt.c +++ b/lib/protocols/mqtt.c @@ -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; } /***************************************************************************** */