staging: r8188eu: simplify control flow
authorSevinj Aghayeva <sevinj.aghayeva@gmail.com>
Sun, 3 Apr 2022 16:42:50 +0000 (12:42 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Apr 2022 14:03:00 +0000 (16:03 +0200)
The function iterates an index from 0 to NUM_PMKID_CACHE and returns
the first index for which the condition is true. If no such index is
found, the function returns -1. Current code has a complex control
flow that obfuscates this simple task. Replace it with a loop.

Also, given the shortened function body, replace the long variable
name psecuritypriv with a short variable name p.

Reported by checkpatch:

WARNING: else is not generally useful after a break or return

Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
Link: https://lore.kernel.org/r/20220403164250.GA371601@euclid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_mlme.c

index f94b1536a17714d0477e2d12aa393889737a2d3c..cddd8ab8023687e9759a270787acd6ef58ad32e8 100644 (file)
@@ -1637,26 +1637,13 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_
 
 static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid)
 {
-       struct security_priv *psecuritypriv = &Adapter->securitypriv;
-       int i = 0;
-
-       do {
-               if ((psecuritypriv->PMKIDList[i].bUsed) &&
-                   (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) {
-                       break;
-               } else {
-                       i++;
-                       /* continue; */
-               }
-
-       } while (i < NUM_PMKID_CACHE);
+       struct security_priv *p = &Adapter->securitypriv;
+       int i;
 
-       if (i == NUM_PMKID_CACHE) {
-               i = -1;/*  Could not find. */
-       } else {
-               /*  There is one Pre-Authentication Key for the specific BSSID. */
-       }
-       return i;
+       for (i = 0; i < NUM_PMKID_CACHE; i++)
+               if (p->PMKIDList[i].bUsed && !memcmp(p->PMKIDList[i].Bssid, bssid, ETH_ALEN))
+                       return i;
+       return -1;
 }
 
 /*  */