diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2022-03-08 15:35:35 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2022-03-21 13:51:52 +0100 |
commit | 41e602a9d75ef121f8a785963bd3d95d2f58ddcd (patch) | |
tree | 588d188a1c6282adbb755efd1dd798852cf6f208 | |
parent | 87150ce960e2ad37b0548db139f38a5ce6affe74 (diff) | |
download | network-manager-applet-41e602a9d75ef121f8a785963bd3d95d2f58ddcd.tar.gz |
editor: improve Wi-Fi security combo error handling
The nma_*_new() functions are wrappers around g_object_new() and
generally don't return NULL. If they do, something seriously went wrong
and freaking out is generally a more sensible reaction than just
skipping a combo box item.
-rw-r--r-- | src/connection-editor/page-wifi-security.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/src/connection-editor/page-wifi-security.c b/src/connection-editor/page-wifi-security.c index b54de903..5260d08c 100644 --- a/src/connection-editor/page-wifi-security.c +++ b/src/connection-editor/page-wifi-security.c @@ -341,88 +341,88 @@ finish_setup (CEPageWifiSecurity *self, gpointer user_data) } ws_wep = nma_ws_wep_key_new (connection, NM_WEP_KEY_TYPE_KEY, FALSE, FALSE); - if (ws_wep) { - add_security_item (self, NMA_WS (ws_wep), sec_model, - &iter, _("WEP 40/128-bit Key (Hex or ASCII)"), - TRUE, TRUE); - if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_KEY)) - active = item; - item++; - } + g_return_if_fail (ws_wep); + + add_security_item (self, NMA_WS (ws_wep), sec_model, + &iter, _("WEP 40/128-bit Key (Hex or ASCII)"), + TRUE, TRUE); + if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_KEY)) + active = item; + item++; ws_wep = nma_ws_wep_key_new (connection, NM_WEP_KEY_TYPE_PASSPHRASE, FALSE, FALSE); - if (ws_wep) { - add_security_item (self, NMA_WS (ws_wep), sec_model, - &iter, _("WEP 128-bit Passphrase"), TRUE, TRUE); - if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE)) - active = item; - item++; - } + g_return_if_fail (ws_wep); + + add_security_item (self, NMA_WS (ws_wep), sec_model, + &iter, _("WEP 128-bit Passphrase"), TRUE, TRUE); + if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE)) + active = item; + item++; } if (security_valid (NMU_SEC_LEAP, mode)) { NMAWsLeap *ws_leap; ws_leap = nma_ws_leap_new (connection, FALSE); - if (ws_leap) { - add_security_item (self, NMA_WS (ws_leap), sec_model, - &iter, _("LEAP"), FALSE, FALSE); - if ((active < 0) && (default_type == NMU_SEC_LEAP)) - active = item; - item++; - } + g_return_if_fail (ws_leap); + + add_security_item (self, NMA_WS (ws_leap), sec_model, + &iter, _("LEAP"), FALSE, FALSE); + if ((active < 0) && (default_type == NMU_SEC_LEAP)) + active = item; + item++; } if (security_valid (NMU_SEC_DYNAMIC_WEP, mode)) { NMAWsDynamicWep *ws_dynamic_wep; ws_dynamic_wep = nma_ws_dynamic_wep_new (connection, TRUE, FALSE); - if (ws_dynamic_wep) { - add_security_item (self, NMA_WS (ws_dynamic_wep), sec_model, - &iter, _("Dynamic WEP (802.1X)"), FALSE, FALSE); - if ((active < 0) && (default_type == NMU_SEC_DYNAMIC_WEP)) - active = item; - item++; - } + g_return_if_fail (ws_dynamic_wep); + + add_security_item (self, NMA_WS (ws_dynamic_wep), sec_model, + &iter, _("Dynamic WEP (802.1X)"), FALSE, FALSE); + if ((active < 0) && (default_type == NMU_SEC_DYNAMIC_WEP)) + active = item; + item++; } if (security_valid (NMU_SEC_WPA_PSK, mode) || security_valid (NMU_SEC_WPA2_PSK, mode)) { NMAWsWpaPsk *ws_wpa_psk; ws_wpa_psk = nma_ws_wpa_psk_new (connection, FALSE); - if (ws_wpa_psk) { - add_security_item (self, NMA_WS (ws_wpa_psk), sec_model, - &iter, _("WPA & WPA2 Personal"), TRUE, TRUE); - if ((active < 0) && ((default_type == NMU_SEC_WPA_PSK) || (default_type == NMU_SEC_WPA2_PSK))) - active = item; - item++; - } + g_return_if_fail (ws_wpa_psk); + + add_security_item (self, NMA_WS (ws_wpa_psk), sec_model, + &iter, _("WPA & WPA2 Personal"), TRUE, TRUE); + if ((active < 0) && ((default_type == NMU_SEC_WPA_PSK) || (default_type == NMU_SEC_WPA2_PSK))) + active = item; + item++; } if (security_valid (NMU_SEC_WPA_ENTERPRISE, mode) || security_valid (NMU_SEC_WPA2_ENTERPRISE, mode)) { NMAWsWpaEap *ws_wpa_eap; ws_wpa_eap = nma_ws_wpa_eap_new (connection, TRUE, FALSE, NULL); - if (ws_wpa_eap) { - add_security_item (self, NMA_WS (ws_wpa_eap), sec_model, - &iter, _("WPA & WPA2 Enterprise"), FALSE, FALSE); - if ((active < 0) && ((default_type == NMU_SEC_WPA_ENTERPRISE) || (default_type == NMU_SEC_WPA2_ENTERPRISE))) - active = item; - item++; - } + g_return_if_fail (ws_wpa_eap); + + add_security_item (self, NMA_WS (ws_wpa_eap), sec_model, + &iter, _("WPA & WPA2 Enterprise"), FALSE, FALSE); + if ((active < 0) && ((default_type == NMU_SEC_WPA_ENTERPRISE) || (default_type == NMU_SEC_WPA2_ENTERPRISE))) + active = item; + item++; } if (security_valid (NMU_SEC_SAE, mode)) { NMAWsSae *ws_sae; ws_sae = nma_ws_sae_new (connection, FALSE); - if (ws_sae) { - add_security_item (self, NMA_WS (ws_sae), sec_model, - &iter, _("WPA3 Personal"), TRUE, TRUE); - if ((active < 0) && ((default_type == NMU_SEC_SAE))) - active = item; - item++; - } + g_return_if_fail (ws_sae); + + add_security_item (self, NMA_WS (ws_sae), sec_model, + &iter, _("WPA3 Personal"), TRUE, TRUE); + if ((active < 0) && ((default_type == NMU_SEC_SAE))) + active = item; + item++; } if (security_valid (NMU_SEC_OWE, mode)) { |