lkml.org 
[lkml]   [2022]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] staging: r8188eu: simplify control flow
From
Hi Sevinj,

On 4/3/22 18:51, Sevinj Aghayeva wrote:
> 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>
> ---

[code snip]

> + 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;
> }
>
> /* */

Looks good, but let's not introduce new checkpatch issue:

CHECK: Alignment should match open parenthesis
#62: FILE: drivers/staging/r8188eu/core/rtw_mlme.c:1645:
+ if ((p->PMKIDList[i].bUsed) &&
+ (!memcmp(p->PMKIDList[i].Bssid, bssid, ETH_ALEN)))




With regards,
Pavel Skripkin

\
 
 \ /
  Last update: 2022-04-03 18:00    [W:0.050 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site