Skip to content

Commit d745689

Browse files
rluboskartben
authored andcommitted
net: mqtt_sn: Verify result of transport initialization
The result of the transport init() function should be propagated to the application, otherwise the initialization could fail silently. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent a04e9fd commit d745689

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/net/lib/mqtt_sn/mqtt_sn.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,8 @@ int mqtt_sn_client_init(struct mqtt_sn_client *client, const struct mqtt_sn_data
10001000
struct mqtt_sn_transport *transport, mqtt_sn_evt_cb_t evt_cb, void *tx,
10011001
size_t txsz, void *rx, size_t rxsz)
10021002
{
1003+
int ret = 0;
1004+
10031005
if (!client || !client_id || !transport || !evt_cb || !tx || !rx) {
10041006
return -EINVAL;
10051007
}
@@ -1020,10 +1022,10 @@ int mqtt_sn_client_init(struct mqtt_sn_client *client, const struct mqtt_sn_data
10201022
k_work_init_delayable(&client->process_work, process_work);
10211023

10221024
if (transport->init) {
1023-
transport->init(transport);
1025+
ret = transport->init(transport);
10241026
}
10251027

1026-
return 0;
1028+
return ret;
10271029
}
10281030

10291031
void mqtt_sn_client_deinit(struct mqtt_sn_client *client)

0 commit comments

Comments
 (0)