net/mqtt: return error codes from net_context_send

Instead of returning EIO let's bubble the error from net_context_send
back up to the caller in the following functions:
mqtt_tx_connect()
mqtt_tx_disconnect()
mqtt_tx_pub_msgs()
mqtt_tx_publish()
mqtt_tx_pingreq()
mqtt_tx_subscribe()
mqtt_tx_unsubscribe()

Change-Id: I9bb4396b227b8902ac1195a97bc37eb1959b643e
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This commit is contained in:
Michael Scott 2017-03-01 23:15:17 -08:00 committed by Jukka Rissanen
commit 438492843c

View file

@ -53,7 +53,6 @@ int mqtt_tx_connect(struct mqtt_ctx *ctx, struct mqtt_connect_msg *msg)
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
net_pkt_unref(tx);
}
@ -93,7 +92,6 @@ int mqtt_tx_disconnect(struct mqtt_ctx *ctx)
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
goto exit_disconnect;
}
@ -167,7 +165,6 @@ int mqtt_tx_pub_msgs(struct mqtt_ctx *ctx, u16_t id,
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
goto exit_send;
}
@ -229,7 +226,6 @@ int mqtt_tx_publish(struct mqtt_ctx *ctx, struct mqtt_publish_msg *msg)
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
net_pkt_unref(tx);
}
@ -268,7 +264,6 @@ int mqtt_tx_pingreq(struct mqtt_ctx *ctx)
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
goto exit_pingreq;
}
@ -312,7 +307,6 @@ int mqtt_tx_subscribe(struct mqtt_ctx *ctx, u16_t pkt_id, u8_t items,
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
net_pkt_unref(tx);
}
@ -356,7 +350,6 @@ int mqtt_tx_unsubscribe(struct mqtt_ctx *ctx, u16_t pkt_id, u8_t items,
rc = net_context_send(tx, NULL, ctx->net_timeout, NULL, NULL);
if (rc < 0) {
rc = -EIO;
net_pkt_unref(tx);
}