staging: ks7010: refactor hostif_sme_set_pmksa function
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Tue, 24 Apr 2018 13:50:07 +0000 (15:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Apr 2018 13:50:20 +0000 (15:50 +0200)
This commits refactor a bit hostif_sme_set_pmksa function:
 - avoid one level indentation changing if condition.
 - use ether_addr_copy to copy bssid addresses.
 - move 'i' initialization to declaration place.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_hostif.c

index 8476ec8e3091e5f7c05fd84ff2f47100034a95d9..9a05374d950ec1b04c202720512f9511334ef4ca 100644 (file)
@@ -2059,16 +2059,14 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
                } __packed list[PMK_LIST_MAX];
        } __packed pmkcache;
        struct pmk *pmk;
-       int i;
+       int i = 0;
 
-       i = 0;
        list_for_each_entry(pmk, &priv->pmklist.head, list) {
-               if (i < PMK_LIST_MAX) {
-                       memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
-                       memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
-                              IW_PMKID_LEN);
-                       i++;
-               }
+               if (i >= PMK_LIST_MAX)
+                       break;
+               ether_addr_copy(pmkcache.list[i].bssid, pmk->bssid);
+               memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN);
+               i++;
        }
        pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
        hostif_mib_set_request(priv, LOCAL_PMK,