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:
Robert Lubos 2025-05-07 15:07:04 +02:00 committed by Benjamin Cabé
commit d745689fe7

View file

@ -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)