--- libaitmqtt/src/sub.c 2022/09/15 15:04:44 1.3.12.3 +++ libaitmqtt/src/sub.c 2022/09/16 04:14:03 1.3.12.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: sub.c,v 1.3.12.3 2022/09/15 15:04:44 misho Exp $ +* $Id: sub.c,v 1.3.12.4 2022/09/16 04:14:03 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -54,7 +54,7 @@ SUCH DAMAGE. * return: NULL error or allocated SUBSCRIBE message */ mqtt_msg_t * -mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, u_short msgID) +mqtt_msgSUBSCRIBE(mqtt_subscr_t * __restrict Topics, u_short msgID) { int len, siz; u_int n, *l; @@ -65,7 +65,7 @@ mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, void *data; mqtt_msg_t *msg = NULL; - if (!Topics || !*Topics) + if (!Topics) return NULL; if (!msgID) { mqtt_SetErr(EINVAL, "Invalid MessageID parameter must be >0"); @@ -74,7 +74,7 @@ mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, /* calculate message size */ len = sizeof(mqtt_len_t); /* msgid */ - for (t = *Topics; t && t->sub_topic.msg_base; t++) /* subscribes & qos */ + for (t = Topics; t && t->sub_topic.msg_base; t++) /* subscribes & qos */ len += sizeof(mqtt_len_t) + t->sub_topic.msg_len + 1; /* calculate header size */ @@ -102,7 +102,7 @@ mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, data += sizeof(mqtt_len_t); /* payload with subscriptions */ - for (t = *Topics; t && t->sub_topic.msg_base; t++) { + for (t = Topics; t && t->sub_topic.msg_base; t++) { topic = (mqtthdr_var_t*) data; topic->var_sb.val = htons(t->sub_topic.msg_len); memcpy(topic->var_data, t->sub_topic.msg_base, ntohs(topic->var_sb.val)); @@ -122,7 +122,7 @@ mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, * return: NULL error or allocated SUBACK message */ mqtt_msg_t * -mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_short msgID) +mqtt_msgSUBACK(mqtt_subscr_t * __restrict Topics, u_short msgID) { int siz = 0; struct mqtthdr *hdr; @@ -131,7 +131,7 @@ mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s u_char *qos; mqtt_msg_t *msg = NULL; - if (!Topics || !*Topics) + if (!Topics) return NULL; if (!(msg = mqtt_msgAlloc(MQTTMSG_MAX))) @@ -147,7 +147,7 @@ mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s v->val = htons(msgID); /* QoS payload from subscriptions */ - for (t = *Topics; t && t->sub_topic.msg_base; t++, siz++) { + for (t = Topics; t && t->sub_topic.msg_base; t++, siz++) { qos = (msg->msg_base + siz); *qos = t->sub_qos; } @@ -169,7 +169,7 @@ mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s * return: NULL error or allocated UNSUBSCRIBE message */ mqtt_msg_t * -mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, u_short msgID, +mqtt_msgUNSUBSCRIBE(mqtt_subscr_t * __restrict Topics, u_short msgID, u_char Dup, u_char QOS) { int len, siz = 0; @@ -181,7 +181,7 @@ mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics void *data; mqtt_msg_t *msg = NULL; - if (!Topics || !*Topics) + if (!Topics) return NULL; if (QOS > MQTT_QOS_EXACTLY) { mqtt_SetErr(EINVAL, "Invalid QoS parameter"); @@ -194,7 +194,7 @@ mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics /* calculate message size */ len = sizeof(mqtt_len_t); /* msgid */ - for (t = *Topics; t && t->sub_topic.msg_base; t++) /* subscribes */ + for (t = Topics; t && t->sub_topic.msg_base; t++) /* subscribes */ len += sizeof(mqtt_len_t) + t->sub_topic.msg_len; /* calculate header size */ @@ -224,7 +224,7 @@ mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics data += sizeof(mqtt_len_t); /* payload with subscriptions */ - for (t = *Topics; t && t->sub_topic.msg_base; t++) { + for (t = Topics; t && t->sub_topic.msg_base; t++) { topic = (mqtthdr_var_t*) data; topic->var_sb.val = htons(t->sub_topic.msg_len); memcpy(topic->var_data, t->sub_topic.msg_base, ntohs(topic->var_sb.val));