core: don't assert in nm_device_get_connection()

This function used to be used only from activation paths, so it
was fine to assert there because we always expected that there
would be an activation request.  These days we'd like to use it
in more places, so just return NULL if there's no connection.
This commit is contained in:
Dan Williams 2012-02-23 13:58:41 -06:00
parent fbfdecf380
commit 0eb09bc99b
3 changed files with 8 additions and 7 deletions

View file

@ -854,8 +854,11 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
NMDBusManager *dbus_mgr; NMDBusManager *dbus_mgr;
DBusGConnection *g_connection; DBusGConnection *g_connection;
gboolean dun = FALSE; gboolean dun = FALSE;
NMConnection *connection;
priv->bt_type = get_connection_bt_type (nm_device_get_connection (device)); connection = nm_device_get_connection (device);
g_assert (connection);
priv->bt_type = get_connection_bt_type (connection);
if (priv->bt_type == NM_BT_CAPABILITY_NONE) { if (priv->bt_type == NM_BT_CAPABILITY_NONE) {
// FIXME: set a reason code // FIXME: set a reason code
return NM_ACT_STAGE_RETURN_FAILURE; return NM_ACT_STAGE_RETURN_FAILURE;

View file

@ -804,7 +804,7 @@ build_supplicant_config (NMDeviceEthernet *self)
NMConnection *connection; NMConnection *connection;
connection = nm_device_get_connection (NM_DEVICE (self)); connection = nm_device_get_connection (NM_DEVICE (self));
g_return_val_if_fail (connection, NULL); g_assert (connection);
con_uuid = nm_connection_get_uuid (connection); con_uuid = nm_connection_get_uuid (connection);
config = nm_supplicant_config_new (); config = nm_supplicant_config_new ();
@ -1079,6 +1079,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
connection = nm_device_get_connection (NM_DEVICE (self)); connection = nm_device_get_connection (NM_DEVICE (self));
g_assert (connection);
security = nm_connection_get_setting_802_1x (connection); security = nm_connection_get_setting_802_1x (connection);
if (!security) { if (!security) {
nm_log_err (LOGD_DEVICE, "Invalid or missing 802.1X security"); nm_log_err (LOGD_DEVICE, "Invalid or missing 802.1X security");

View file

@ -632,12 +632,9 @@ nm_device_get_act_request (NMDevice *self)
NMConnection * NMConnection *
nm_device_get_connection (NMDevice *self) nm_device_get_connection (NMDevice *self)
{ {
NMActRequest *req; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
req = nm_device_get_act_request (self); return priv->act_request ? nm_act_request_get_connection (priv->act_request) : NULL;
g_assert (req);
return nm_act_request_get_connection (req);
} }
gboolean gboolean