From: Greg KH <gregkh@linuxfoundation.org>
To: Briana Oursler <briana.oursler@gmail.com>
Cc: nramas@linux.microsoft.com, forest@alittletooquiet.net,
outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy][PATCH v3] Staging: vt6655: Refactor switch case statement.
Date: Fri, 27 Mar 2020 10:00:43 +0100 [thread overview]
Message-ID: <20200327090043.GA1663713@kroah.com> (raw)
In-Reply-To: <20200327025301.74819-1-briana.oursler@gmail.com>
On Thu, Mar 26, 2020 at 07:53:01PM -0700, Briana Oursler wrote:
> Pull some logic branches above switch case. Create variables to reduce
> code duplication and improve readability.
>
> Signed-off-by: Briana Oursler <briana.oursler@gmail.com>
> ---
>
> Changes in v3:
> - Update grammar and meaning in patch description.
>
> Changes in v2:
> - Remove ternary logic in switch case.
> - Introduce 'flag' bool.
> - Move len definition above switch case.
>
> drivers/staging/vt6655/rxtx.c | 128 ++++++++++++++++++----------------
> 1 file changed, 66 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
> index 37fcc42ed000..5b45d66b7f39 100644
> --- a/drivers/staging/vt6655/rxtx.c
> +++ b/drivers/staging/vt6655/rxtx.c
> @@ -239,11 +239,21 @@ s_uGetDataDuration(
> )
> {
> bool bLastFrag = false;
> + bool flag = false;
> unsigned int uAckTime = 0, uNextPktTime = 0;
> + unsigned int len;
>
> if (uFragIdx == (uMACfragNum - 1))
> bLastFrag = true;
>
> + if (uFragIdx == (uMACfragNum - 2))
> + len = cbLastFragmentSize;
> + else
> + len = cbFrameLength;
> +
> + if (byFBOption == AUTO_FB_0)
> + flag = true;
"flag" is horrible to try to remember what it really is for.
You already know this, because you say so in your code change:
> + /* flag true if (byFBOption == AUTO_FB_0) */
> + if (flag) {
Why not just test for the == statement here?
Also, your comment is indented incorrectly, didn't checkpatch catch that
when you ran it against your patch?
> + /* flag true if (byFBOption == AUTO_FB_0) */
> + if (flag) {
Same goes here as well.
I don't see why adding that new variable saved any space or logic, it
only made the code harder to follow and forced you to write the logic
out anyway, in the comment :)
thanks,
greg k-h
next prev parent reply other threads:[~2020-03-27 9:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 4:55 [Outreachy} [PATCH] Staging: vt6655: Refactor switch case statement Briana Oursler
2020-03-25 12:35 ` Greg KH
2020-03-25 17:46 ` [Outreachy] " Briana Oursler
2020-03-25 17:48 ` Briana Oursler
2020-03-25 18:01 ` Briana Oursler
2020-03-25 19:34 ` Briana Oursler
2020-03-27 0:33 ` [PATCH v2] " Briana Oursler
2020-03-27 1:14 ` [Outreachy kernel] " Lakshmi Ramasubramanian
2020-03-27 2:53 ` [Outreachy][PATCH v3] " Briana Oursler
2020-03-27 9:00 ` Greg KH [this message]
2020-03-27 21:32 ` [Outreachy][Patch v4] " Briana Oursler
2020-03-27 21:40 ` [Outreachy kernel] " Julia Lawall
2020-03-28 5:10 ` [patch v5] Staging: vt6655: Reduce statement complexity Briana Oursler
2020-03-28 10:19 ` Julia Lawall
2020-03-29 1:05 ` Briana Oursler
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=20200327090043.GA1663713@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=briana.oursler@gmail.com \
--cc=forest@alittletooquiet.net \
--cc=nramas@linux.microsoft.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.