From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E41C6C433F5 for ; Fri, 8 Apr 2022 04:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234207AbiDHERV (ORCPT ); Fri, 8 Apr 2022 00:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbiDHERT (ORCPT ); Fri, 8 Apr 2022 00:17:19 -0400 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C1FC2D9A28 for ; Thu, 7 Apr 2022 21:15:16 -0700 (PDT) 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) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > >