From 063ab8da5cb50fbca9f134aa15c7927035b5036c Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 11 Dec 2014 10:13:59 +0100 Subject: device: turn nm_d_ip_config_should_fail to get_ip_config_may_fail Has a cleaner semantics and will be useful later on. Also, make it static -- it's not used outside nm-device.c. --- src/devices/nm-device-private.h | 2 -- src/devices/nm-device.c | 29 +++++++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index fd87fd77a1..65a9a71af4 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -56,8 +56,6 @@ void nm_device_take_down (NMDevice *self, gboolean block); gboolean nm_device_set_hw_addr (NMDevice *device, const char *addr, const char *detail, guint64 hw_log_domain); -gboolean nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6); - void nm_device_set_firmware_missing (NMDevice *self, gboolean missing); void nm_device_activate_schedule_stage1_device_prepare (NMDevice *device); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 169db19dfb..e366e1dec9 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2215,11 +2215,11 @@ activation_source_schedule (NMDevice *self, GSourceFunc func, int family) } } -gboolean -nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6) +static gboolean +get_ip_config_may_fail (NMDevice *self, int family) { NMConnection *connection; - NMSettingIPConfig *s_ip4, *s_ip6; + NMSettingIPConfig *s_ip = NULL; g_return_val_if_fail (self != NULL, TRUE); @@ -2227,17 +2227,18 @@ nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6) g_assert (connection); /* Fail the connection if the failed IP method is required to complete */ - if (ip6) { - s_ip6 = nm_connection_get_setting_ip6_config (connection); - if (!nm_setting_ip_config_get_may_fail (s_ip6)) - return TRUE; - } else { - s_ip4 = nm_connection_get_setting_ip4_config (connection); - if (!nm_setting_ip_config_get_may_fail (s_ip4)) - return TRUE; + switch (family) { + case AF_INET: + s_ip = nm_connection_get_setting_ip4_config (connection); + break; + case AF_INET6: + s_ip = nm_connection_get_setting_ip6_config (connection); + break; + default: + g_assert_not_reached (); } - return FALSE; + return nm_setting_ip_config_get_may_fail (s_ip); } static void @@ -4668,7 +4669,7 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self) static NMActStageReturn act_stage4_ip4_config_timeout (NMDevice *self, NMDeviceStateReason *reason) { - if (nm_device_ip_config_should_fail (self, FALSE)) { + if (!get_ip_config_may_fail (self, AF_INET)) { *reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; return NM_ACT_STAGE_RETURN_FAILURE; } @@ -4746,7 +4747,7 @@ nm_device_activate_schedule_ip4_config_timeout (NMDevice *self) static NMActStageReturn act_stage4_ip6_config_timeout (NMDevice *self, NMDeviceStateReason *reason) { - if (nm_device_ip_config_should_fail (self, TRUE)) { + if (!get_ip_config_may_fail (self, AF_INET6)) { *reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; return NM_ACT_STAGE_RETURN_FAILURE; } -- cgit v1.2.1