nm-device-ethernet: refactor act_stage1_prepare code

Refactored the code a bit without changing functionality: let the function
immediately return on error.
This commit is contained in:
Francesco Giudici
2016-09-08 18:12:37 +02:00
parent 16fdef33dd
commit 61faa5080e

View File

@@ -799,17 +799,17 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
{ {
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev); NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActStageReturn ret;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason); ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason);
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE)) return ret;
ret = NM_ACT_STAGE_RETURN_FAILURE;
} if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE))
return NM_ACT_STAGE_RETURN_FAILURE;
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
/* If we're re-activating a PPPoE connection a short while after /* If we're re-activating a PPPoE connection a short while after
* a previous PPPoE connection was torn down, wait a bit to allow the * a previous PPPoE connection was torn down, wait a bit to allow the
* remote side to handle the disconnection. Otherwise the peer may * remote side to handle the disconnection. Otherwise the peer may
@@ -826,13 +826,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
priv->pppoe_wait_id = g_timeout_add_seconds (delay, priv->pppoe_wait_id = g_timeout_add_seconds (delay,
pppoe_reconnect_delay, pppoe_reconnect_delay,
self); self);
ret = NM_ACT_STAGE_RETURN_POSTPONE; return NM_ACT_STAGE_RETURN_POSTPONE;
} else }
priv->last_pppoe_time = 0; priv->last_pppoe_time = 0;
} }
}
return ret; return NM_ACT_STAGE_RETURN_SUCCESS;
} }
static NMActStageReturn static NMActStageReturn