summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-05-24 21:56:29 +0200
committerThomas Haller <thaller@redhat.com>2017-05-24 22:00:05 +0200
commit4f69c1e85e58d024fedcfde641b3dbfcbf3e834c (patch)
tree96e06da13c2eab2c3900e1c74aca79ed988b7824 /clients
parent31656a066bfb3edc106f5efd5d2be46396824930 (diff)
downloadNetworkManager-4f69c1e85e58d024fedcfde641b3dbfcbf3e834c.tar.gz
cli: prettify check_activated() to by using switch() statement
No change in behavior.
Diffstat (limited to 'clients')
-rw-r--r--clients/cli/connections.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 5224ab784f..d4a955b238 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -2095,12 +2095,10 @@ check_activated (ActivateConnectionInfo *info)
NmCli *nmc = info->nmc;
NMDevice *device = info->device;
NMActiveConnection *active = info->active;
- NMActiveConnectionState ac_state;
NMActiveConnectionStateReason ac_reason;
NMDeviceState dev_state;
NMDeviceStateReason dev_reason;
- ac_state = nm_active_connection_get_state (active);
ac_reason = nm_active_connection_get_state_reason (active);
if (device) {
@@ -2108,14 +2106,19 @@ check_activated (ActivateConnectionInfo *info)
dev_reason = nm_device_get_state_reason (device);
}
- if (ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+ switch (nm_active_connection_get_state (active)) {
+
+ case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
activate_connection_info_finish (info);
- } else if (ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
- if (device && ac_reason == NM_ACTIVE_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED) {
+ break;
+
+ case NM_ACTIVE_CONNECTION_STATE_DEACTIVATED:
+ if ( device
+ && ac_reason == NM_ACTIVE_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED) {
if (dev_state == NM_DEVICE_STATE_FAILED || dev_state == NM_DEVICE_STATE_DISCONNECTED) {
g_string_printf (nmc->return_text, _("Error: Connection activation failed: %s"),
nmc_device_reason_to_string (dev_reason));
@@ -2131,7 +2134,9 @@ check_activated (ActivateConnectionInfo *info)
nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
activate_connection_info_finish (info);
}
- } else if (ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING) {
+ break;
+
+ case NM_ACTIVE_CONNECTION_STATE_ACTIVATING:
/* activating master connection does not automatically activate any slaves, so their
* active connection state will not progress beyond ACTIVATING state.
* Monitor the device instead. */
@@ -2147,14 +2152,18 @@ check_activated (ActivateConnectionInfo *info)
&& ( NM_IS_DEVICE_BOND (device)
|| NM_IS_DEVICE_TEAM (device)
|| NM_IS_DEVICE_BRIDGE (device))
- && dev_state >= NM_DEVICE_STATE_IP_CONFIG
- && dev_state <= NM_DEVICE_STATE_ACTIVATED) {
+ && dev_state >= NM_DEVICE_STATE_IP_CONFIG
+ && dev_state <= NM_DEVICE_STATE_ACTIVATED) {
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
g_print (_("Connection successfully activated (master waiting for slaves) (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
activate_connection_info_finish (info);
}
+ break;
+
+ default:
+ break;
}
}