From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25D5F367; Fri, 8 Apr 2022 04:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=uTabu/53bsyjVq/ChwDFv7CtxaAxu/V7Z38X06Q53J8=; b=GCcL5h9eISAZu40VAIaRYGmVcO2zZWvbtlq4m0c24CoerRPi4HxCPVTo FnnS2mXXBEIcrSfMSyldAZgPP+2NgsQ2WX+TcXBt3TQ87QJIOytjey1iA l8mbqpKak2PwBsHsxpCQDS5tUpMHGGIIqBollj7SXqDt9U1gFsL/xVTpx 8=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.90,243,1643670000"; d="scan'208";a="30688890" Received: from lputeaux-656-1-153-249.w217-128.abo.wanadoo.fr (HELO hadrien) ([217.128.47.249]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 06:15:14 +0200 Date: Fri, 8 Apr 2022 06:15:14 +0200 (CEST) From: Julia Lawall X-X-Sender: julia@hadrien To: Rebecca Mckeever cc: outreachy@lists.linux.dev, Greg Kroah-Hartman , 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 In-Reply-To: <36059ec66a2f3d58a8e339aa4f262772eabd3ef0.1649378587.git.remckee0@gmail.com> Message-ID: References: <36059ec66a2f3d58a8e339aa4f262772eabd3ef0.1649378587.git.remckee0@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 > --- > 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 > > >