From 073346ee3785deb50c0ec0523e4cd22225299b46 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 11 Jan 2022 11:00:15 -0600 Subject: [PATCH] treewide: Remove unneeded else statements The code is more readable without the unnecessary nesting --- src/dpp.c | 5 +++-- src/eapol.c | 8 ++++---- src/network.c | 4 ++-- src/p2p.c | 5 +++-- src/station.c | 7 ++++--- src/wiphy.c | 14 +++++++------- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 19727e5e..98d2a75c 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -1707,8 +1707,9 @@ static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus, if (station && station_get_connected_network(station)) { l_warn("cannot be enrollee while connected, please disconnect"); return dbus_error_busy(message); - } else - l_debug("No station device, continuing anyways..."); + } + + l_debug("No station device, continuing anyways..."); dpp->uri = dpp_generate_uri(dpp->pub_asn1, dpp->pub_asn1_len, 2, netdev_get_address(dpp->netdev), &freq, diff --git a/src/eapol.c b/src/eapol.c index 19f70b54..9f397d1d 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -2389,12 +2389,12 @@ static void eapol_eap_complete_cb(enum eap_result result, void *user_data) sm->eap = NULL; handshake_failed(sm, MMPDU_REASON_CODE_IEEE8021X_FAILED); return; - } else { - if (install_pmk) - install_pmk(sm->handshake, sm->handshake->pmk, - sm->handshake->pmk_len); } + if (install_pmk) + install_pmk(sm->handshake, sm->handshake->pmk, + sm->handshake->pmk_len); + eap_reset(sm->eap); if (sm->handshake->authenticator) { diff --git a/src/network.c b/src/network.c index 9a2d12cf..10937ab7 100644 --- a/src/network.c +++ b/src/network.c @@ -996,8 +996,8 @@ bool network_bss_add(struct network *network, struct scan_bss *bss) /* Done if BSS is not HS20 or we already have network_info set */ if (!bss->hs20_capable) return true; - else - network->is_hs20 = true; + + network->is_hs20 = true; if (network->info) return true; diff --git a/src/p2p.c b/src/p2p.c index 65471f09..9e863865 100644 --- a/src/p2p.c +++ b/src/p2p.c @@ -1597,8 +1597,9 @@ static void p2p_peer_provision_done(int err, struct wsc_credentials_info *creds, p2p_connection_reset(dev); return; - } else - goto error; + } + + goto error; } if (strlen(creds[0].ssid) != bss->ssid_len || diff --git a/src/station.c b/src/station.c index b04c1b15..b9a6efe1 100644 --- a/src/station.c +++ b/src/station.c @@ -237,9 +237,10 @@ static int station_autoconnect_next(struct station *station) } return 0; - } else - l_debug("autoconnect: network_autoconnect: %s (%d)", - strerror(-r), r); + } + + l_debug("autoconnect: network_autoconnect: %s (%d)", + strerror(-r), r); } return -ENOENT; diff --git a/src/wiphy.c b/src/wiphy.c index bd2094a8..b6b0f563 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -209,14 +209,14 @@ static bool wiphy_can_connect_sae(struct wiphy *wiphy) * TODO: No support for CMD_EXTERNAL_AUTH yet. */ return false; - } else { - /* Case (2) */ - if (wiphy_has_ext_feature(wiphy, - NL80211_EXT_FEATURE_SAE_OFFLOAD)) - return true; - - return false; } + + /* Case (2) */ + if (wiphy_has_ext_feature(wiphy, + NL80211_EXT_FEATURE_SAE_OFFLOAD)) + return true; + + return false; } enum ie_rsn_akm_suite wiphy_select_akm(struct wiphy *wiphy,