diff options
author | Thomas Haller <thaller@redhat.com> | 2020-01-02 15:03:39 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-08 09:47:57 +0100 |
commit | e9d4980d6b22b90ef1017b9c94bfc6ce2b6ceafe (patch) | |
tree | 9a03245fb08f2ccc979fc62c1df3aecd47ea807e | |
parent | 936bb8716b6b9c925cf40145a1565f5522dc696c (diff) | |
download | NetworkManager-e9d4980d6b22b90ef1017b9c94bfc6ce2b6ceafe.tar.gz |
libnm: cleanup conditions by moving pre-check in nm_utils_security_valid()
Do the switch based on the type on the top level, don't split the
conditions to first handle some cases, and some later.
-rw-r--r-- | libnm-core/nm-utils.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 7d6e159b84..f5da87b7c5 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -1166,21 +1166,10 @@ nm_utils_security_valid (NMUtilsSecurityType type, NM80211ApSecurityFlags ap_wpa, NM80211ApSecurityFlags ap_rsn) { - if (!have_ap) { - if (type == NMU_SEC_NONE) - return TRUE; - if ( (type == NMU_SEC_STATIC_WEP) - || ((type == NMU_SEC_DYNAMIC_WEP) && !adhoc) - || ((type == NMU_SEC_LEAP) && !adhoc)) { - if (wifi_caps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) - return TRUE; - return FALSE; - } - } - switch (type) { case NMU_SEC_NONE: - g_assert (have_ap); + if (!have_ap) + return TRUE; if (ap_flags & NM_802_11_AP_FLAGS_PRIVACY) return FALSE; if ( ap_wpa @@ -1192,7 +1181,11 @@ nm_utils_security_valid (NMUtilsSecurityType type, return FALSE; /* fall through */ case NMU_SEC_STATIC_WEP: - g_assert (have_ap); + if (!have_ap) { + if (wifi_caps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) + return TRUE; + return FALSE; + } if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) return FALSE; if ( ap_wpa @@ -1206,7 +1199,11 @@ nm_utils_security_valid (NMUtilsSecurityType type, case NMU_SEC_DYNAMIC_WEP: if (adhoc) return FALSE; - g_assert (have_ap); + if (!have_ap) { + if (wifi_caps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) + return TRUE; + return FALSE; + } if ( ap_rsn || !(ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) return FALSE; |