Skip to content

Commit 5928399

Browse files
committed
Updates based on peer review. Added checks for null and return code.
1 parent 71ad3c1 commit 5928399

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

examples/mqttclient/mqttclient.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ int mqttclient_test(MQTTCtx *mqttCtx)
153153

154154
#ifdef WOLFMQTT_DISCONNECT_CB
155155
/* setup disconnect callback */
156-
MqttClient_SetDisconnectCallback(&mqttCtx->client, mqtt_disconnect_cb, NULL);
156+
rc = MqttClient_SetDisconnectCallback(&mqttCtx->client,
157+
mqtt_disconnect_cb, NULL);
158+
if (rc != MQTT_CODE_SUCCESS) {
159+
goto exit;
160+
}
157161
#endif
158162

159163
FALL_THROUGH;

src/mqtt_packet.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ static int MqttPacket_HandleNetError(MqttClient *client, int rc)
703703
rc != MQTT_CODE_STDIN_WAKE)
704704
{
705705
/* don't use return code for now - future use */
706-
client->disconnect_cb(client, rc, client->disconnect_ctx);
706+
if (client->disconnect_cb)
707+
client->disconnect_cb(client, rc, client->disconnect_ctx);
707708
}
708709
#endif
709710
return rc;

0 commit comments

Comments
 (0)