Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp134353pxw; Fri, 8 Apr 2022 03:29:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+VUKlqqN//Vy9FDZPe+iz/ogxQMAPKernRHToHp/gCigzwVrsRbNyvzO2FBJW44lVT4Iv X-Received: by 2002:a05:6402:51d2:b0:419:7d2e:9d0 with SMTP id r18-20020a05640251d200b004197d2e09d0mr18721443edd.82.1649413762409; Fri, 08 Apr 2022 03:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649413762; cv=none; d=google.com; s=arc-20160816; b=a+J4rX1Qh7B23lYgrsV3JtSHYudvxg3TraxeBjO2IR4Y5Fd2/ID0MF9qb8NiCnpjtj HjZbjJJy4Ch9tivrKrzKbCYDYqE1K3AgQy+UxBipTW/hOtYK3RACxsYtGLaC8ysMamGC qIAgOX7N3l7OPe7PI7pSts/s8V4LE2jf0XceN52z5e/snQHlx4h+LZ2bwsMBLLJ/WNnq kY1RvvTWaAlMcdeQhM7oaN2xhR1er2WNKt4GmsVMUF5BEZE2+qL5228nwgPe3y7MU/1Y Lc3W/CgSrLieqLepswkxiDAAk8wfOlTsQaoJlfj2KYePwAXP/8epBLD7rnsBMipd4u3L qGhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=fZZ16rD9b0u2RViOVs+LJJdsC5uqvAuSjxxabYBNoi0=; b=f4BrjQDx14dezfrur1jec8dYUM/zFo2Ic+GDUl0uVxIzMe4l31sg95txUV6sZFH7tN p7RT9oc0xVnBYeNQ8UA8NpBAuY0qScgdHSgN4oLZzbIBhmit2Kk8lIP7jNFVp50igsJS v1Kn0te87UJQYVtywgXrTZ+FhOkDlL8G458FrVmAj39urHqzH0gjA30qOCKb9l9pPhGt Fndbc2h7ojquLtD9UQc63HQqW+L8OasNV1orgTj6Q4bDGME6BMEKZw6HGD/pDVljjdDE 1UXJlapVlTbm2a/96NLoRCWWdDvmjg5Nq6y9Upv25yRC3Sza6zBmQl/18pfWJAjUy2KS Np5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=URLpjXWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr10-20020a056402222a00b0041949d8911fsi549555edb.73.2022.04.08.03.28.56; Fri, 08 Apr 2022 03:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=URLpjXWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232333AbiDHIxG (ORCPT + 99 others); Fri, 8 Apr 2022 04:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbiDHIxE (ORCPT ); Fri, 8 Apr 2022 04:53:04 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF4B20C2C1 for ; Fri, 8 Apr 2022 01:50:59 -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=fZZ16rD9b0u2RViOVs+LJJdsC5uqvAuSjxxabYBNoi0=; b=URLpjXWkCOdrk2HRgoR9ugF8+E7LejuRz+d85uUlryZ15T5PLQ3javxl GztOI4W9tQAAH4G3XHeXSBSTGnDB0hG26ePOLyGXW/0D14V0VvKsooEko vKZWA3pc/Vx9RGovReEQx//trqRHgYGUjawPyudk5zBBc/w8rTlarLcXE I=; Authentication-Results: mail3-relais-sop.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,244,1643670000"; d="scan'208";a="10959734" Received: from unknown (HELO hadrien) ([95.128.147.62]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 10:50:58 +0200 Date: Fri, 8 Apr 2022 10:50:57 +0200 (CEST) From: Julia Lawall X-X-Sender: julia@hadrien To: Dan Carpenter cc: Rebecca Mckeever , 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: <20220408055732.GO3293@kadam> Message-ID: References: <36059ec66a2f3d58a8e339aa4f262772eabd3ef0.1649378587.git.remckee0@gmail.com> <20220408055732.GO3293@kadam> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 Apr 2022, Dan Carpenter wrote: > On Fri, Apr 08, 2022 at 06:15:14AM +0200, Julia Lawall wrote: > > 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? > > Initially Rebecca did use max() but I NAKed it. It's really not less > readable. Better to handle the error explicitly. Keep the error path > indented two tabs. Separate from the success path. OK. I have a hard time seeing that as an error path, though, with no return or goto. I guess it's error and recover. OK either way. julia