Merge pull request #116 from DavidLin1577/patch-1

Minor optimization to improve readability of code
This commit is contained in:
Arthur
2020-03-06 11:28:48 +08:00
committed by GitHub
2 changed files with 6 additions and 6 deletions

View File

@@ -4,7 +4,7 @@
## 整体框架 ## 整体框架
![整体框架](./png/mqttclient.png) ![整体框架](./png/mqttclient.png)
> 备注目前只支持linux及encentOS tiny系统 > 备注目前只支持linux及TencentOS tiny系统
## linux平台下测试使用 ## linux平台下测试使用
### 安装cmake ### 安装cmake
@@ -311,7 +311,7 @@ mqtt_ack_list_unrecord(c, UNSUBACK, packet_id, &msg_handler)
``` ```
3. 销毁对应的订阅消息处理函数 3. 销毁对应的订阅消息处理函数
```c ```c
mqtt_msg_handler_destory(msg_handler); mqtt_msg_handler_destroy(msg_handler);
``` ```
## 来自服务器的`发布`报文的处理 ## 来自服务器的`发布`报文的处理
```c ```c

View File

@@ -401,7 +401,7 @@ static message_handlers_t *mqtt_msg_handler_create(const char* topic_filter, mqt
return msg_handler; return msg_handler;
} }
static void mqtt_msg_handler_destory(message_handlers_t *msg_handler) static void mqtt_msg_handler_destroy(message_handlers_t *msg_handler)
{ {
if (NULL != &msg_handler->list) { if (NULL != &msg_handler->list) {
list_del(&msg_handler->list); list_del(&msg_handler->list);
@@ -435,7 +435,7 @@ static int mqtt_msg_handler_is_exist(mqtt_client_t* c, message_handlers_t *handl
static int mqtt_msg_handlers_install(mqtt_client_t* c, message_handlers_t *handler) static int mqtt_msg_handlers_install(mqtt_client_t* c, message_handlers_t *handler)
{ {
if (mqtt_msg_handler_is_exist(c, handler)) { if (mqtt_msg_handler_is_exist(c, handler)) {
mqtt_msg_handler_destory(handler); mqtt_msg_handler_destroy(handler);
RETURN_ERROR(MQTT_SUCCESS_ERROR); RETURN_ERROR(MQTT_SUCCESS_ERROR);
} }
@@ -620,7 +620,7 @@ static int mqtt_suback_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR); RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
if (is_nack) { if (is_nack) {
mqtt_msg_handler_destory(msg_handler); mqtt_msg_handler_destroy(msg_handler);
RETURN_ERROR(MQTT_SUBSCRIBE_NOT_ACK_ERROR); RETURN_ERROR(MQTT_SUBSCRIBE_NOT_ACK_ERROR);
} }
@@ -643,7 +643,7 @@ static int mqtt_unsuback_packet_handle(mqtt_client_t *c, platform_timer_t *timer
if (!msg_handler) if (!msg_handler)
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR); RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
mqtt_msg_handler_destory(msg_handler); mqtt_msg_handler_destroy(msg_handler);
RETURN_ERROR(rc); RETURN_ERROR(rc);
} }