Commit 9f2d13a6 authored by Sevinj Aghayeva's avatar Sevinj Aghayeva Committed by Greg Kroah-Hartman

staging: rtl8712: simplify control flow

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: default avatarSevinj Aghayeva <sevinj.aghayeva@gmail.com>
Link: https://lore.kernel.org/r/20220403165325.GA374638@euclidSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8a4b1870
...@@ -1257,26 +1257,13 @@ int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie, u8 *out_ie, ...@@ -1257,26 +1257,13 @@ int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie, u8 *out_ie,
*/ */
static int SecIsInPMKIDList(struct _adapter *Adapter, u8 *bssid) static int SecIsInPMKIDList(struct _adapter *Adapter, u8 *bssid)
{ {
struct security_priv *psecuritypriv = &Adapter->securitypriv; struct security_priv *p = &Adapter->securitypriv;
int i = 0; int i;
do {
if (psecuritypriv->PMKIDList[i].bUsed &&
(!memcmp(psecuritypriv->PMKIDList[i].Bssid,
bssid, ETH_ALEN)))
break;
i++;
} while (i < NUM_PMKID_CACHE);
if (i == NUM_PMKID_CACHE) { for (i = 0; i < NUM_PMKID_CACHE; i++)
i = -1; /* Could not find. */ if (p->PMKIDList[i].bUsed && !memcmp(p->PMKIDList[i].Bssid, bssid, ETH_ALEN))
} else { return i;
; /* There is one Pre-Authentication Key for the return -1;
* specific BSSID.
*/
}
return i;
} }
sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment