summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-22 13:06:27 +0200
committerThomas Haller <thaller@redhat.com>2018-10-23 10:47:01 +0200
commit4f27164148d0c796851b2f82553915f9296ac7cd (patch)
treec8e2a98cc177e6f7a7be8ee0e8f4ea64ba233aa7
parentaf48af4671031d3f6ff3e019c854d24402ef0d04 (diff)
downloadNetworkManager-4f27164148d0c796851b2f82553915f9296ac7cd.tar.gz
core: don't cast return value of nm_device_get_applied_setting()
-rw-r--r--src/devices/adsl/nm-device-adsl.c13
-rw-r--r--src/devices/nm-device-bond.c8
-rw-r--r--src/devices/nm-device-ethernet.c43
-rw-r--r--src/devices/nm-device-infiniband.c3
-rw-r--r--src/devices/nm-device-macsec.c17
-rw-r--r--src/devices/nm-device-ppp.c6
-rw-r--r--src/devices/nm-device-vlan.c2
-rw-r--r--src/devices/nm-device-wpan.c6
-rw-r--r--src/devices/nm-device.c20
-rw-r--r--src/devices/ovs/nm-device-ovs-interface.c7
-rw-r--r--src/devices/team/nm-device-team.c1
-rw-r--r--src/devices/wifi/nm-device-iwd.c2
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c5
-rw-r--r--src/devices/wifi/nm-device-wifi.c22
14 files changed, 89 insertions, 66 deletions
diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c
index 9cec81920f..ddc03ce3b1 100644
--- a/src/devices/adsl/nm-device-adsl.c
+++ b/src/devices/adsl/nm-device-adsl.c
@@ -259,8 +259,9 @@ pppoe_vcc_config (NMDeviceAdsl *self)
NMDevice *device = NM_DEVICE (self);
NMSettingAdsl *s_adsl;
- s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device));
- g_assert (s_adsl);
+ s_adsl = nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
+
+ g_return_val_if_fail (s_adsl, FALSE);
/* Set up the VCC */
if (!br2684_assign_vcc (self, s_adsl))
@@ -389,7 +390,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMSettingAdsl *s_adsl;
const char *protocol;
- s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device));
+ s_adsl = nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
+
g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE);
protocol = nm_setting_adsl_get_protocol (s_adsl);
@@ -465,8 +467,11 @@ act_stage3_ip4_config_start (NMDevice *device,
const char *ppp_iface;
req = nm_device_get_act_request (device);
+
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
- s_adsl = (NMSettingAdsl *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
+
+ s_adsl = nm_device_get_applied_setting (device, NM_TYPE_SETTING_ADSL);
+
g_return_val_if_fail (s_adsl, NM_ACT_STAGE_RETURN_FAILURE);
/* PPPoE uses the NAS interface, not the ATM interface */
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 6e7e6ffcd1..ae986ae3c0 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -220,7 +220,6 @@ static NMActStageReturn
apply_bonding_config (NMDevice *device)
{
NMDeviceBond *self = NM_DEVICE_BOND (device);
- NMConnection *connection;
NMSettingBond *s_bond;
int ifindex = nm_device_get_ifindex (device);
const char *mode_str, *value;
@@ -241,10 +240,9 @@ apply_bonding_config (NMDevice *device)
* arp_interval doesn't require miimon to be 0
*/
- connection = nm_device_get_applied_connection (device);
- g_assert (connection);
- s_bond = nm_connection_get_setting_bond (connection);
- g_assert (s_bond);
+ s_bond = nm_device_get_applied_setting (device, NM_TYPE_SETTING_BOND);
+
+ g_return_val_if_fail (s_bond, NM_ACT_STAGE_RETURN_FAILURE);
mode_str = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE);
if (!mode_str)
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 1587a2a343..d527a49371 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -556,7 +556,9 @@ build_supplicant_config (NMDeviceEthernet *self,
guint32 mtu;
connection = nm_device_get_applied_connection (NM_DEVICE (self));
- g_assert (connection);
+
+ g_return_val_if_fail (connection, NULL);
+
con_uuid = nm_connection_get_uuid (connection);
mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)),
nm_device_get_ifindex (NM_DEVICE (self)));
@@ -790,7 +792,7 @@ link_negotiation_set (NMDevice *device)
guint32 speed = 0;
guint32 link_speed;
- s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
+ s_wired = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
if (s_wired) {
autoneg = nm_setting_wired_get_auto_negotiate (s_wired);
speed = nm_setting_wired_get_speed (s_wired);
@@ -880,8 +882,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
delay);
g_assert (!priv->pppoe_wait_id);
priv->pppoe_wait_id = g_timeout_add_seconds (delay,
- pppoe_reconnect_delay,
- self);
+ pppoe_reconnect_delay,
+ self);
return NM_ACT_STAGE_RETURN_POSTPONE;
}
priv->last_pppoe_time = 0;
@@ -900,6 +902,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *out_failure
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
connection = nm_device_get_applied_connection (NM_DEVICE (self));
+
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
security = nm_connection_get_setting_802_1x (connection);
@@ -995,10 +998,12 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *out_
NMActRequest *req;
GError *err = NULL;
- req = nm_device_get_act_request (NM_DEVICE (self));
+ req = nm_device_get_act_request (device);
+
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
- s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE);
+ s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE);
+
g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (device),
@@ -1069,8 +1074,10 @@ dcb_configure (NMDevice *device)
nm_clear_g_source (&priv->dcb_timeout_id);
- s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
- g_assert (s_dcb);
+ s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
+
+ g_return_val_if_fail (s_dcb, FALSE);
+
if (!nm_dcb_setup (nm_device_get_iface (device), s_dcb, &error)) {
_LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s",
error->message);
@@ -1199,7 +1206,8 @@ wake_on_lan_enable (NMDevice *device)
NMSettingWired *s_wired;
const char *password = NULL;
- s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
+ s_wired = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
+
if (s_wired) {
wol = nm_setting_wired_get_wake_on_lan (s_wired);
password = nm_setting_wired_get_wake_on_lan_password (s_wired);
@@ -1240,8 +1248,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
NMSettingDcb *s_dcb;
- s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device,
- NM_TYPE_SETTING_CONNECTION));
+ s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION);
+
g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE);
nm_clear_g_source (&priv->dcb_timeout_id);
@@ -1254,8 +1262,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
NMSetting8021x *security;
- security = (NMSetting8021x *) nm_device_get_applied_setting (device,
- NM_TYPE_SETTING_802_1X);
+ security = nm_device_get_applied_setting (device, NM_TYPE_SETTING_802_1X);
+
if (security) {
/* FIXME: for now 802.1x is mutually exclusive with DCB */
return nm_8021x_stage2_config (self, out_failure_reason);
@@ -1265,7 +1273,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
wake_on_lan_enable (device);
/* DCB and FCoE setup */
- s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
+ s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
if (s_dcb) {
/* lldpad really really wants the carrier to be up */
if (nm_platform_link_is_connected (nm_device_get_platform (device), nm_device_get_ifindex (device))) {
@@ -1288,7 +1296,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NM_SETTING_PPPOE_SETTING_NAME)) {
NMSettingPpp *s_ppp;
- s_ppp = (NMSettingPpp *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
+ s_ppp = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
if (s_ppp) {
guint32 mtu = 0, mru = 0, mxu;
@@ -1316,7 +1324,8 @@ act_stage3_ip4_config_start (NMDevice *device,
NMSettingConnection *s_con;
const char *connection_type;
- s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION));
+ s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION);
+
g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE);
connection_type = nm_setting_connection_get_connection_type (s_con);
@@ -1358,7 +1367,7 @@ deactivate (NMDevice *device)
priv->dcb_handle_carrier_changes = FALSE;
/* Tear down DCB/FCoE if it was enabled */
- s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
+ s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
if (s_dcb) {
if (!nm_dcb_cleanup (nm_device_get_iface (device), &error)) {
_LOGW (LOGD_DEVICE | LOGD_PLATFORM, "failed to disable DCB/FCoE: %s",
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index 41fac157dd..afb5655580 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -86,7 +86,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
- s_infiniband = (NMSettingInfiniband *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_INFINIBAND);
+ s_infiniband = nm_device_get_applied_setting (device, NM_TYPE_SETTING_INFINIBAND);
+
g_return_val_if_fail (s_infiniband, NM_ACT_STAGE_RETURN_FAILURE);
transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband);
diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c
index 8ea4c8b562..60e2fc2fb9 100644
--- a/src/devices/nm-device-macsec.c
+++ b/src/devices/nm-device-macsec.c
@@ -210,7 +210,7 @@ update_properties (NMDevice *device)
static NMSupplicantConfig *
build_supplicant_config (NMDeviceMacsec *self, GError **error)
{
- NMSupplicantConfig *config = NULL;
+ gs_unref_object NMSupplicantConfig *config = NULL;
NMSettingMacsec *s_macsec;
NMSetting8021x *s_8021x;
NMConnection *connection;
@@ -218,19 +218,21 @@ build_supplicant_config (NMDeviceMacsec *self, GError **error)
guint32 mtu;
connection = nm_device_get_applied_connection (NM_DEVICE (self));
- g_assert (connection);
+
+ g_return_val_if_fail (connection, NULL);
+
con_uuid = nm_connection_get_uuid (connection);
mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)),
nm_device_get_ifindex (NM_DEVICE (self)));
config = nm_supplicant_config_new (FALSE, FALSE);
- s_macsec = (NMSettingMacsec *)
- nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC);
+ s_macsec = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC);
+
+ g_return_val_if_fail (s_macsec, NULL);
if (!nm_supplicant_config_add_setting_macsec (config, s_macsec, error)) {
g_prefix_error (error, "macsec-setting: ");
- g_object_unref (config);
return NULL;
}
@@ -238,11 +240,11 @@ build_supplicant_config (NMDeviceMacsec *self, GError **error)
s_8021x = nm_connection_get_setting_802_1x (connection);
if (!nm_supplicant_config_add_setting_8021x (config, s_8021x, con_uuid, mtu, TRUE, error)) {
g_prefix_error (error, "802-1x-setting: ");
- g_clear_object (&config);
+ return NULL;
}
}
- return config;
+ return g_steal_pointer (&config);
}
static void
@@ -588,6 +590,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
const char *setting_name;
connection = nm_device_get_applied_connection (NM_DEVICE (self));
+
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
if (!priv->supplicant.mgr)
diff --git a/src/devices/nm-device-ppp.c b/src/devices/nm-device-ppp.c
index 3a3f9054a1..2f565d4b1f 100644
--- a/src/devices/nm-device-ppp.c
+++ b/src/devices/nm-device-ppp.c
@@ -125,10 +125,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMActRequest *req;
GError *error = NULL;
- req = nm_device_get_act_request (NM_DEVICE (self));
+ req = nm_device_get_act_request (device);
+
g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE);
- s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE);
+ s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE);
+
g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE);
g_clear_object (&priv->ip4_config);
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index b7f0c4e756..c07112ab98 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -493,7 +493,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
parent_mtu_maybe_changed (parent_device, NULL, device);
}
- s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
+ s_vlan = nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
if (s_vlan) {
gs_free NMVlanQosMapping *ingress_map = NULL;
gs_free NMVlanQosMapping *egress_map = NULL;
diff --git a/src/devices/nm-device-wpan.c b/src/devices/nm-device-wpan.c
index 35352df12b..7aa70aa3cb 100644
--- a/src/devices/nm-device-wpan.c
+++ b/src/devices/nm-device-wpan.c
@@ -118,7 +118,6 @@ static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMDeviceWpan *self = NM_DEVICE_WPAN (device);
- NMConnection *connection;
NMSettingWpan *s_wpan;
NMPlatform *platform;
guint16 pan_id;
@@ -139,12 +138,11 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
g_return_val_if_fail (platform, NM_ACT_STAGE_RETURN_FAILURE);
ifindex = nm_device_get_ifindex (device);
+
g_return_val_if_fail (ifindex > 0, NM_ACT_STAGE_RETURN_FAILURE);
- connection = nm_device_get_applied_connection (device);
- g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
+ s_wpan = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WPAN);
- s_wpan = NM_SETTING_WPAN (nm_connection_get_setting (connection, NM_TYPE_SETTING_WPAN));
g_return_val_if_fail (s_wpan, NM_ACT_STAGE_RETURN_FAILURE);
hwaddr = nm_platform_link_get_address (platform, ifindex, &hwaddr_len);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 645e8dff8a..14015d9da3 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1954,9 +1954,10 @@ nm_device_get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *iid, gboo
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
if (!ignore_token) {
- s_ip6 = (NMSettingIP6Config *)
- nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
+ s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
+
g_return_val_if_fail (s_ip6, FALSE);
+
token = nm_setting_ip6_config_get_token (s_ip6);
}
if (token)
@@ -4933,12 +4934,12 @@ check_ip_state (NMDevice *self, gboolean may_fail, gboolean full_state_update)
&& !priv->is_enslaved)
return;
- s_ip4 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
+ s_ip4 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
if (s_ip4 && nm_streq0 (nm_setting_ip_config_get_method (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
ip4_disabled = TRUE;
- s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
+ s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
if (s_ip6 && nm_streq0 (nm_setting_ip_config_get_method (s_ip6),
NM_SETTING_IP6_CONFIG_METHOD_IGNORE))
ip6_ignore = TRUE;
@@ -6237,7 +6238,7 @@ act_stage1_prepare (NMDevice *self, NMDeviceStateReason *out_failure_reason)
if ( priv->ifindex > 0
&& nm_device_has_capability (self, NM_DEVICE_CAP_SRIOV)
- && (s_sriov = (NMSettingSriov *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))) {
+ && (s_sriov = nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))) {
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
gs_free_error GError *error = NULL;
NMSriovVF *vf;
@@ -9026,7 +9027,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
if (mtu_desired && mtu_desired < 1280) {
NMSettingIPConfig *s_ip6;
- s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
+ s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
if ( s_ip6
&& !NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
@@ -14375,7 +14376,8 @@ nm_device_spawn_iface_helper (NMDevice *self)
return;
connection = nm_device_get_applied_connection (self);
- g_assert (connection);
+
+ g_return_if_fail (connection);
argv = g_ptr_array_sized_new (10);
g_ptr_array_set_free_func (argv, g_free);
@@ -15799,7 +15801,9 @@ nm_device_get_supplicant_timeout (NMDevice *self)
g_return_val_if_fail (NM_IS_DEVICE (self), SUPPLICANT_DEFAULT_TIMEOUT);
connection = nm_device_get_applied_connection (self);
+
g_return_val_if_fail (connection, SUPPLICANT_DEFAULT_TIMEOUT);
+
s_8021x = nm_connection_get_setting_802_1x (connection);
if (s_8021x) {
timeout = nm_setting_802_1x_get_auth_timeout (s_8021x);
@@ -15830,7 +15834,7 @@ nm_device_auth_retries_try_next (NMDevice *self)
if (G_UNLIKELY (auth_retries == NM_DEVICE_AUTH_RETRIES_UNSET)) {
auth_retries = -1;
- s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (self, NM_TYPE_SETTING_CONNECTION));
+ s_con = nm_device_get_applied_setting (self, NM_TYPE_SETTING_CONNECTION);
if (s_con)
auth_retries = nm_setting_connection_get_auth_retries (s_con);
diff --git a/src/devices/ovs/nm-device-ovs-interface.c b/src/devices/ovs/nm-device-ovs-interface.c
index 2b48fae683..960b8f3582 100644
--- a/src/devices/ovs/nm-device-ovs-interface.c
+++ b/src/devices/ovs/nm-device-ovs-interface.c
@@ -121,12 +121,13 @@ link_changed (NMDevice *device,
static gboolean
_is_internal_interface (NMDevice *device)
{
- NMConnection *connection = nm_device_get_applied_connection (device);
- NMSettingOvsInterface *s_ovs_iface = nm_connection_get_setting_ovs_interface (connection);
+ NMSettingOvsInterface *s_ovs_iface;
+
+ s_ovs_iface = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OVS_INTERFACE);
g_return_val_if_fail (s_ovs_iface, FALSE);
- return strcmp (nm_setting_ovs_interface_get_interface_type (s_ovs_iface), "internal") == 0;
+ return nm_streq (nm_setting_ovs_interface_get_interface_type (s_ovs_iface), "internal");
}
static NMActStageReturn
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 899932fd4b..950e22526a 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -626,6 +626,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
connection = nm_device_get_applied_connection (device);
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
+
s_team = nm_connection_get_setting_team (connection);
g_return_val_if_fail (s_team, NM_ACT_STAGE_RETURN_FAILURE);
diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c
index 5a601b7412..2f308737a8 100644
--- a/src/devices/wifi/nm-device-iwd.c
+++ b/src/devices/wifi/nm-device-iwd.c
@@ -1518,7 +1518,7 @@ act_start_cb (GObject *source, GAsyncResult *res, gpointer user_data)
nm_assert (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG);
- s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
+ s_wireless = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
if (!s_wireless)
goto error;
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index 178cea66c7..0b21616271 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -181,16 +181,13 @@ static NMActStageReturn
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
- NMConnection *connection;
NMSettingOlpcMesh *s_mesh;
guint32 channel;
GBytes *ssid;
const char *anycast_addr;
- connection = nm_device_get_applied_connection (device);
- g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
+ s_mesh = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OLPC_MESH);
- s_mesh = nm_connection_get_setting_olpc_mesh (connection);
g_return_val_if_fail (s_mesh, NM_ACT_STAGE_RETURN_FAILURE);
channel = nm_setting_olpc_mesh_get_channel (s_mesh);
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 1e68b44edc..c8b9ee81de 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -1868,9 +1868,10 @@ need_new_8021x_secrets (NMDeviceWifi *self,
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
NMConnection *connection;
- g_assert (setting_name != NULL);
+ g_return_val_if_fail (setting_name, FALSE);
connection = nm_device_get_applied_connection (NM_DEVICE (self));
+
g_return_val_if_fail (connection != NULL, FALSE);
/* 802.1x stuff only happens in the supplicant's ASSOCIATED state when it's
@@ -1922,10 +1923,11 @@ need_new_wpa_psk (NMDeviceWifi *self,
NMConnection *connection;
const char *key_mgmt = NULL;
- g_assert (setting_name != NULL);
+ g_return_val_if_fail (setting_name, FALSE);
connection = nm_device_get_applied_connection (NM_DEVICE (self));
- g_return_val_if_fail (connection != NULL, FALSE);
+
+ g_return_val_if_fail (connection, FALSE);
/* A bad PSK will cause the supplicant to disconnect during the 4-way handshake */
if (old_state != NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE)
@@ -2057,15 +2059,12 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
* schedule the next activation stage.
*/
if (devstate == NM_DEVICE_STATE_CONFIG) {
- NMConnection *connection;
NMSettingWireless *s_wifi;
GBytes *ssid;
gs_free char *ssid_str = NULL;
- connection = nm_device_get_applied_connection (NM_DEVICE (self));
- g_return_if_fail (connection);
+ s_wifi = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
- s_wifi = nm_connection_get_setting_wireless (connection);
g_return_if_fail (s_wifi);
ssid = nm_setting_wireless_get_ssid (s_wifi);
@@ -2486,7 +2485,7 @@ wake_on_wlan_enable (NMDeviceWifi *self)
NMSettingWirelessWakeOnWLan wowl;
NMSettingWireless *s_wireless;
- s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
+ s_wireless = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
if (s_wireless) {
wowl = nm_setting_wireless_get_wake_on_wlan (s_wireless);
if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT)
@@ -2663,7 +2662,8 @@ set_powersave (NMDevice *device)
NMSettingWireless *s_wireless;
NMSettingWirelessPowersave val;
- s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
+ s_wireless = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
+
g_return_if_fail (s_wireless);
val = nm_setting_wireless_get_powersave (s_wireless);
@@ -2813,6 +2813,7 @@ act_stage3_ip4_config_start (NMDevice *device,
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
connection = nm_device_get_applied_connection (device);
+
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
@@ -2836,6 +2837,7 @@ act_stage3_ip6_config_start (NMDevice *device,
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
connection = nm_device_get_applied_connection (device);
+
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip6 = nm_connection_get_setting_ip6_config (connection);
@@ -2935,6 +2937,7 @@ act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *out_failur
NMActStageReturn ret;
connection = nm_device_get_applied_connection (device);
+
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
@@ -2956,6 +2959,7 @@ act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *out_failur
NMActStageReturn ret;
connection = nm_device_get_applied_connection (device);
+
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
s_ip6 = nm_connection_get_setting_ip6_config (connection);