All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jes Sorensen <jes.sorensen@gmail.com>
To: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>,
	 outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH] Staging: rtl8192u: Remove else after return
Date: Fri, 20 Feb 2015 14:04:05 -0500	[thread overview]
Message-ID: <54E78525.9090308@gmail.com> (raw)
In-Reply-To: <1424457078-5570-1-git-send-email-ksenija.stanojevic@gmail.com>

On 02/20/15 13:31, Ksenija Stanojevic wrote:
> This patch simplifies the code by removing else and fixes
> the following checkpatch.pl warning: "else is not useful after
> break or return".
> 
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> ---
>  drivers/staging/rtl8192u/r819xU_phy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c
> index e210664..00be1fd 100644
> --- a/drivers/staging/rtl8192u/r819xU_phy.c
> +++ b/drivers/staging/rtl8192u/r819xU_phy.c
> @@ -1363,11 +1363,11 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
>  			if ((*stage) == 2) {
>  				(*delay) = CurrentCmd->msDelay;
>  				return true;
> -			} else {
> -				(*stage)++;
> -				(*step) = 0;
> -				continue;
>  			}
> +			(*stage)++;
> +			(*step) = 0;
> +			continue;
> +
>  		}
>  
>  		switch (CurrentCmd->CmdID) {
> 

There is one issue with your patch, you add a blank line after continue,
that one needs to be removed.

rtl8192_phy_SwChnlStepByStep() is an utter mess, and given that the
function is huge and have a lot of return points, one either has to take
the approach you have chosen or fix them all up. I just told Aybuke
Ozdemir to use a goto to fix a similar case, so I wanted to point out
that here I think your solution makes sense.

There is another bad case with this function in that they return
true/false in a u8 variable, ie. the variable and the values assigned to
it do not match. This would call for a separate patch though.

Cheers,
Jes



  reply	other threads:[~2015-02-20 19:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 18:31 [PATCH] Staging: rtl8192u: Remove else after return Ksenija Stanojevic
2015-02-20 19:04 ` Jes Sorensen [this message]
2015-02-22 18:11   ` [Outreachy kernel] " Ksenija Stanojević

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54E78525.9090308@gmail.com \
    --to=jes.sorensen@gmail.com \
    --cc=ksenija.stanojevic@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.