Re: [PATCH] staging: r8188eu: remove else after return and break statements

From: MAHAK GUPTA
Date: Thu Apr 14 2022 - 18:02:05 EST


Hi Larry and Pavel,
On Wed, Apr 13, 2022 at 10:21 PM Larry Finger <Larry.Finger@xxxxxxxxxxxx> wrote:
>
> On 4/13/22 00:27, Mahak Gupta wrote:
> > Else is not necessary after return and break statements, hence remove
> > it.
> >
> > Reported by checkpatch:
> >
> > WARNING: else is not generally useful after a break or return
> >
> > Signed-off-by: Mahak Gupta <mahak_g@xxxxxxxxxxxxx>
>
> The commit message is redundant. I would suggest the following:
>
> checkpatch reports the following:
>
> WARNING: else is not generally useful after a break or return
>
> Remove those cases.
This patch is merged by Greg now but I'll keep this in mind for next
patches. Thanks

>
>
> > ---
> > drivers/staging/r8188eu/core/rtw_ieee80211.c | 41 ++++++++------------
> > 1 file changed, 17 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c
> > index 5a0e42ed4a47..bb4c9bc864da 100644
> > --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c
> > +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c
> > @@ -97,16 +97,15 @@ bool rtw_is_cckratesonly_included(u8 *rate)
> >
> > int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
> > {
> > - if (channel > 14) {
> > + if (channel > 14)
> > return WIRELESS_INVALID;
> > - } else { /* could be pure B, pure G, or B/G */
> > - if (rtw_is_cckratesonly_included(rate))
> > - return WIRELESS_11B;
> > - else if (rtw_is_cckrates_included(rate))
> > - return WIRELESS_11BG;
> > - else
> > - return WIRELESS_11G;
> > - }
> > + /* could be pure B, pure G, or B/G */
> > + if (rtw_is_cckratesonly_included(rate))
> > + return WIRELESS_11B;
> > + else if (rtw_is_cckrates_included(rate))
> > + return WIRELESS_11BG;
> > + else
> > + return WIRELESS_11G;
>
> Is this 'else' necessary?
Yeah, we can remove this else too, sorry didn't notice it. Should I
submit another patch removing this?

>
>
> Larry

Mahak