From 0eb09bc99be8111b44b54162691ee7e71c081dc2 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 23 Feb 2012 13:58:41 -0600 Subject: [PATCH] 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. --- src/nm-device-bt.c | 5 ++++- src/nm-device-ethernet.c | 3 ++- src/nm-device.c | 7 ++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/nm-device-bt.c b/src/nm-device-bt.c index 524c25362d..964e2d765a 100644 --- a/src/nm-device-bt.c +++ b/src/nm-device-bt.c @@ -854,8 +854,11 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) NMDBusManager *dbus_mgr; DBusGConnection *g_connection; 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) { // FIXME: set a reason code return NM_ACT_STAGE_RETURN_FAILURE; diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c index 3889a398cc..0d42c2bfd8 100644 --- a/src/nm-device-ethernet.c +++ b/src/nm-device-ethernet.c @@ -804,7 +804,7 @@ build_supplicant_config (NMDeviceEthernet *self) NMConnection *connection; 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); config = nm_supplicant_config_new (); @@ -1079,6 +1079,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; connection = nm_device_get_connection (NM_DEVICE (self)); + g_assert (connection); security = nm_connection_get_setting_802_1x (connection); if (!security) { nm_log_err (LOGD_DEVICE, "Invalid or missing 802.1X security"); diff --git a/src/nm-device.c b/src/nm-device.c index 5a3b1ebc5f..7bbecafce4 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -632,12 +632,9 @@ nm_device_get_act_request (NMDevice *self) NMConnection * nm_device_get_connection (NMDevice *self) { - NMActRequest *req; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - req = nm_device_get_act_request (self); - g_assert (req); - - return nm_act_request_get_connection (req); + return priv->act_request ? nm_act_request_get_connection (priv->act_request) : NULL; } gboolean