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>
This commit is contained in:
parent
a04e9fd0de
commit
d745689fe7
1 changed files with 4 additions and 2 deletions
|
@ -1000,6 +1000,8 @@ int mqtt_sn_client_init(struct mqtt_sn_client *client, const struct mqtt_sn_data
|
|||
struct mqtt_sn_transport *transport, mqtt_sn_evt_cb_t evt_cb, void *tx,
|
||||
size_t txsz, void *rx, size_t rxsz)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!client || !client_id || !transport || !evt_cb || !tx || !rx) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1020,10 +1022,10 @@ int mqtt_sn_client_init(struct mqtt_sn_client *client, const struct mqtt_sn_data
|
|||
k_work_init_delayable(&client->process_work, process_work);
|
||||
|
||||
if (transport->init) {
|
||||
transport->init(transport);
|
||||
ret = transport->init(transport);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mqtt_sn_client_deinit(struct mqtt_sn_client *client)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue