diff options
| author | Sevinj Aghayeva <sevinj.aghayeva@gmail.com> | 2022-04-01 07:46:35 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-04 07:33:49 +0200 |
| commit | 875e957087b5f8624a1fbfe9d9b9647ec7912bd4 (patch) | |
| tree | b18c638a692706797d55412783eaf5b614b62dbf /drivers/staging/rtl8723bs | |
| parent | 47f46a873d9bd29f1d663517eff4a4ad7c1654b9 (diff) | |
| download | cachepc-linux-875e957087b5f8624a1fbfe9d9b9647ec7912bd4.tar.gz cachepc-linux-875e957087b5f8624a1fbfe9d9b9647ec7912bd4.zip | |
staging: rtl8723bs: 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
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
Link: https://lore.kernel.org/r/20220401114635.GA567659@euclid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8723bs')
| -rw-r--r-- | drivers/staging/rtl8723bs/core/rtw_mlme.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index d5bb3a5bd2fb..3eacf8f9d236 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2036,28 +2036,14 @@ 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); - - if (i == NUM_PMKID_CACHE) { - i = -1;/* Could not find. */ - } else { - /* There is one Pre-Authentication Key for the specific BSSID. */ - } - - return i; + struct security_priv *p = &Adapter->securitypriv; + int 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; } /* */ |
