diff options
| author | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
| commit | 9a6dcbf895f9da01768e64b73cec88c16157d91e (patch) | |
| tree | a359958930d731e9f1b59344642e10754419fe84 /src/devices/nm-device-macsec.c | |
| parent | 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 (diff) | |
New upstream version 1.16.0 upstream/1.16.0
Diffstat (limited to 'src/devices/nm-device-macsec.c')
| -rw-r--r-- | src/devices/nm-device-macsec.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c index 8ea4c8b5..1a6b64a4 100644 --- a/src/devices/nm-device-macsec.c +++ b/src/devices/nm-device-macsec.c @@ -210,7 +210,7 @@ update_properties (NMDevice *device) static NMSupplicantConfig * build_supplicant_config (NMDeviceMacsec *self, GError **error) { - NMSupplicantConfig *config = NULL; + gs_unref_object NMSupplicantConfig *config = NULL; NMSettingMacsec *s_macsec; NMSetting8021x *s_8021x; NMConnection *connection; @@ -218,19 +218,21 @@ build_supplicant_config (NMDeviceMacsec *self, GError **error) guint32 mtu; connection = nm_device_get_applied_connection (NM_DEVICE (self)); - g_assert (connection); + + g_return_val_if_fail (connection, NULL); + con_uuid = nm_connection_get_uuid (connection); mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)), nm_device_get_ifindex (NM_DEVICE (self))); config = nm_supplicant_config_new (FALSE, FALSE); - s_macsec = (NMSettingMacsec *) - nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC); + s_macsec = nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC); + + g_return_val_if_fail (s_macsec, NULL); if (!nm_supplicant_config_add_setting_macsec (config, s_macsec, error)) { g_prefix_error (error, "macsec-setting: "); - g_object_unref (config); return NULL; } @@ -238,11 +240,11 @@ build_supplicant_config (NMDeviceMacsec *self, GError **error) s_8021x = nm_connection_get_setting_802_1x (connection); if (!nm_supplicant_config_add_setting_8021x (config, s_8021x, con_uuid, mtu, TRUE, error)) { g_prefix_error (error, "802-1x-setting: "); - g_clear_object (&config); + return NULL; } } - return config; + return g_steal_pointer (&config); } static void @@ -588,6 +590,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) const char *setting_name; connection = nm_device_get_applied_connection (NM_DEVICE (self)); + g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE); if (!priv->supplicant.mgr) @@ -654,7 +657,6 @@ create_and_realize (NMDevice *device, GError **error) { const char *iface = nm_device_get_iface (device); - NMPlatformError plerr; NMSettingMacsec *s_macsec; NMPlatformLnkMacsec lnk = { }; int parent_ifindex; @@ -666,6 +668,7 @@ create_and_realize (NMDevice *device, } s; guint64 u; } sci; + int r; s_macsec = nm_connection_get_setting_macsec (connection); g_assert (s_macsec); @@ -694,13 +697,13 @@ create_and_realize (NMDevice *device, parent_ifindex = nm_device_get_ifindex (parent); g_warn_if_fail (parent_ifindex > 0); - plerr = nm_platform_link_macsec_add (nm_device_get_platform (device), iface, parent_ifindex, &lnk, out_plink); - if (plerr != NM_PLATFORM_ERROR_SUCCESS) { + r = nm_platform_link_macsec_add (nm_device_get_platform (device), iface, parent_ifindex, &lnk, out_plink); + if (r < 0) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create macsec interface '%s' for '%s': %s", iface, nm_connection_get_id (connection), - nm_platform_error_to_string_a (plerr)); + nm_strerror (r)); return FALSE; } |