diff options
author | Thomas Haller <thaller@redhat.com> | 2018-03-14 08:12:10 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-03-18 21:09:56 +0100 |
commit | d60199502756b6dce6b4610e2c5c7f6e1892f086 (patch) | |
tree | e04cf1f50b30891f0fd09f75585075481b61ec55 | |
parent | 78f9528bbe2a0dd728f49301cdeb3ec73c9c2ba2 (diff) | |
download | NetworkManager-d60199502756b6dce6b4610e2c5c7f6e1892f086.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 | 40 |
2 files changed, 28 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 56acc47d49..2e05673d19 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4768,6 +4768,21 @@ nm_device_generate_connection (NMDevice *self, return g_steal_pointer (&connection); } +/** + * nm_device_complete_connection: + * @self: + * @connection: + * @specific_object: + * @existing_connection: + * @error: + * + * 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, @@ -4775,27 +4790,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 |