public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Rebecca Mckeever <remckee0@gmail.com>
Cc: outreachy@lists.linux.dev,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] staging: rtl8192u: replace ternary statement with if and assignment
Date: Fri, 8 Apr 2022 06:15:14 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2204080614400.2199@hadrien> (raw)
In-Reply-To: <36059ec66a2f3d58a8e339aa4f262772eabd3ef0.1649378587.git.remckee0@gmail.com>



On Thu, 7 Apr 2022, Rebecca Mckeever wrote:

> Replace ternary statement with an if statement followed by an assignment
> to increase readability and make error handling more obvious.
> Found with minmax coccinelle script.
>
> Signed-off-by: Rebecca Mckeever <remckee0@gmail.com>
> ---
>  drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> index 78cc8f357bbc..9885917b9199 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> @@ -470,7 +470,9 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
>  		return 0;
>  	}
>  	len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
> -	erq->length = (len >= 0 ? len : 0);
> +	if (len < 0)
> +		len = 0;
> +	erq->length = len;

Maybe you could use max here?

julia

>
>  	erq->flags |= IW_ENCODE_ENABLED;
>
> --
> 2.32.0
>
>
>

  reply	other threads:[~2022-04-08  4:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08  1:12 [PATCH v2 0/2] staging: rtl8192u: cleanup of ternary and if else statements Rebecca Mckeever
2022-04-08  1:12 ` [PATCH v2 1/2] staging: rtl8192u: replace ternary statement with if and assignment Rebecca Mckeever
2022-04-08  4:15   ` Julia Lawall [this message]
2022-04-08  5:09     ` Greg Kroah-Hartman
2022-04-08  5:57     ` Dan Carpenter
2022-04-08  6:14       ` Joe Perches
2022-04-08  6:31         ` Dan Carpenter
2022-04-08  7:19           ` Joe Perches
2022-04-08  8:35             ` Dan Carpenter
2022-04-08  8:50       ` Julia Lawall
2022-04-08  1:12 ` [PATCH v2 2/2] staging: rtl8192u: use min_t/max_t macros instead of if else Rebecca Mckeever
2022-04-08  6:39 ` [PATCH v2 0/2] staging: rtl8192u: cleanup of ternary and if else statements Dan Carpenter

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=alpine.DEB.2.22.394.2204080614400.2199@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    --cc=remckee0@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox