From 0d44b640fcd120c0661f8fbaf98a5b80c0490b60 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 25 Jun 2019 10:42:52 +0200 Subject: wwan/modem-broadband: get rid of g_assert*() Though there is no known way to reach these, it may well happen that this is going to prevent some hard crashes. --- src/devices/wwan/nm-modem-broadband.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 056d302e96..a9239fca34 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -487,9 +487,9 @@ connect_context_step (NMModemBroadband *self) if (mm_modem_get_state (self->_priv.modem_iface) <= MM_MODEM_STATE_LOCKED) break; - /* Create core connect properties based on the modem capabilities */ - g_assert (!ctx->connect_properties); + g_return_if_fail (!ctx->connect_properties); + /* Create core connect properties based on the modem capabilities */ if (MODEM_CAPS_3GPP (ctx->caps)) ctx->connect_properties = create_gsm_connect_properties (ctx->connection); else if (MODEM_CAPS_3GPP2 (ctx->caps)) @@ -502,7 +502,8 @@ connect_context_step (NMModemBroadband *self) connect_context_clear (self); break; } - g_assert (ctx->connect_properties); + + g_return_if_fail (ctx->connect_properties); /* Build up list of IP types that we need to use in the retries */ ctx->ip_types = nm_modem_get_connection_ip_type (NM_MODEM (self), ctx->connection, &error); @@ -533,7 +534,7 @@ connect_context_step (NMModemBroadband *self) else if (current == NM_MODEM_IP_TYPE_IPV4V6) mm_simple_connect_properties_set_ip_type (ctx->connect_properties, MM_BEARER_IP_FAMILY_IPV4V6); else - g_assert_not_reached (); + g_return_if_reached (); _nm_modem_set_apn (NM_MODEM (self), mm_simple_connect_properties_get_apn (ctx->connect_properties)); @@ -863,8 +864,8 @@ static_stage3_ip4_done (NMModemBroadband *self) guint32 ip4_route_table, ip4_route_metric; NMPlatformIP4Route *r; - g_assert (self->_priv.ipv4_config); - g_assert (self->_priv.bearer); + g_return_val_if_fail (self->_priv.ipv4_config, FALSE); + g_return_val_if_fail (self->_priv.bearer, FALSE); self->_priv.idle_id_ip4 = 0; @@ -895,7 +896,7 @@ static_stage3_ip4_done (NMModemBroadband *self) } data_port = mm_bearer_get_interface (self->_priv.bearer); - g_assert (data_port); + g_return_val_if_fail (data_port, FALSE); config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); @@ -970,7 +971,7 @@ stage3_ip6_done (NMModemBroadband *self) const char **dns; guint i; - g_assert (self->_priv.ipv6_config); + g_return_val_if_fail (self->_priv.ipv6_config, FALSE); self->_priv.idle_id_ip6 = 0; memset (&address, 0, sizeof (address)); @@ -1002,7 +1003,8 @@ stage3_ip6_done (NMModemBroadband *self) _LOGI ("IPv6 base configuration:"); data_port = mm_bearer_get_interface (self->_priv.bearer); - g_assert (data_port); + g_return_val_if_fail (data_port, FALSE); + config = nm_ip6_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET), nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); @@ -1370,8 +1372,9 @@ set_property (GObject *object, /* construct-only */ self->_priv.modem_object = g_value_dup_object (value); self->_priv.modem_iface = mm_object_get_modem (self->_priv.modem_object); + g_return_if_fail (self->_priv.modem_iface); self->_priv.modem_3gpp_iface = mm_object_get_modem_3gpp (self->_priv.modem_object); - g_assert (self->_priv.modem_iface != NULL); + g_signal_connect (self->_priv.modem_iface, "state-changed", G_CALLBACK (modem_state_changed), -- cgit v1.2.1