diff options
author | Thomas Haller <thaller@redhat.com> | 2018-03-14 08:12:10 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-03-20 15:08:18 +0100 |
commit | af97b9a41e422524e69adf751caadef53104c07b (patch) | |
tree | 6eeec5c9568fb33f9409f8684893d791b56c8f51 | |
parent | f7b2ebc87adc1a4afae8c89a7ebd94e7e03374ce (diff) | |
download | NetworkManager-af97b9a41e422524e69adf751caadef53104c07b.tar.gz |
device: minor cleanup of nm_device_complete_connection() and add code comment
Regarding the cleanup: remove the success variable and instead error
out early.
-rw-r--r-- | src/devices/adsl/nm-device-adsl.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device.c | 35 |
2 files changed, 23 insertions, 14 deletions
diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index 8675cbf8bc..ed7b868d24 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -135,8 +135,6 @@ complete_connection (NMDevice *device, _("ADSL connection"), NULL, FALSE); /* No IPv6 yet by default */ - - return TRUE; } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6146304e7f..feb2a1b2b0 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4767,6 +4767,16 @@ nm_device_generate_connection (NMDevice *self, return g_steal_pointer (&connection); } +/** + * nm_device_complete_connection: + * + * Complete the connection. This is solely used for AddAndActivate where the user + * may pass in an incomplete connection and a device, and the device tries to + * make sense of it and complete it for activation. Otherwise, this is not + * used. + * + * Returns: success or failure. + */ gboolean nm_device_complete_connection (NMDevice *self, NMConnection *connection, @@ -4774,27 +4784,28 @@ nm_device_complete_connection (NMDevice *self, const GSList *existing_connections, GError **error) { - gboolean success = FALSE; + NMDeviceClass *klass; - g_return_val_if_fail (self != NULL, FALSE); - g_return_val_if_fail (connection != NULL, FALSE); + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + + klass = NM_DEVICE_GET_CLASS (self); - if (!NM_DEVICE_GET_CLASS (self)->complete_connection) { + if (!klass->complete_connection) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "Device class %s had no complete_connection method", G_OBJECT_TYPE_NAME (self)); return FALSE; } - success = NM_DEVICE_GET_CLASS (self)->complete_connection (self, - connection, - specific_object, - existing_connections, - error); - if (success) - success = nm_connection_verify (connection, error); + if (!klass->complete_connection (self, + connection, + specific_object, + existing_connections, + error)) + return FALSE; - return success; + return nm_connection_verify (connection, error); } gboolean |