Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2895396ybb; Mon, 30 Mar 2020 15:29:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtiA9LdcjRvMh+YSQyeqTVEZcoqcbhG9IGhhwVztrhR8hl/FKRfS0zaXqyJrOurVTGmF4RJ X-Received: by 2002:a05:6830:1da6:: with SMTP id z6mr9644895oti.124.1585607360212; Mon, 30 Mar 2020 15:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585607360; cv=none; d=google.com; s=arc-20160816; b=mX9Ar4L2mP8yb365+5Gx1DKrvnwddel+20GnyvX8KqthuZPJM+zyF2tZR45G8kBYVQ zLWEG3azjsaVqa3jx7unZUxUqdxTCqcBVKk51dqnhj4rjDcz8fRBHnuABZ7mYvgx79tY rX15uvkG/2yyu36gTWthLGbCNFcpZCW/FMwcIlKY3wb8Q8fbkFQhsWPLAu+WhpwaOgwt EpCm0w9d7gLcf1iD71GMdKN9EQ0AIF4pZoF8cNPwf/8rCmLGz7n7snxVSRX0taWjVPK2 QfPws+huNtAr6rmpQuVfw+TelcZJVb1fObrEzPEB/86KhwzkxEWg8mHI1eFaR9dLnqdc X1SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=s+MoJHMSmcTUpq3uJxnfw8RVUGWalt2lStS+Ah7bIw8=; b=vYLo0IuoM8UaMWIFckapgOOU26dUKwXV7dURwTPiDSjZk5JtaGVg9vpTJf5b/1vBSY GVsopYbyKgIQ36/9BS1bCab0GBMxR1uIUImPO78wTjYAyq79Zz76AhFF/UE2+mG2M/Gj gmLz6k3Qgzlz6OMQE86bHgnzC9WEaqRaePb2dbojC3XhYDU5IV16FUsLSuONZMU/K8/a TMV+RuXbyUNokOi/kSukcNO04xQ6RNhGiEcjmzQSGTlgvJ3DcvuscHtus+Ydj0MGWYgD meZgEb6EMFEx01uHLKnkRBrcC1cQmjooid1lL039fxzZkJzx1G2DxBsjACg7mOJJH1rE eGBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ycc1KEIO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21si7055346otf.31.2020.03.30.15.29.07; Mon, 30 Mar 2020 15:29:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ycc1KEIO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729489AbgC3W0J (ORCPT + 99 others); Mon, 30 Mar 2020 18:26:09 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38339 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729461AbgC3W0J (ORCPT ); Mon, 30 Mar 2020 18:26:09 -0400 Received: by mail-pl1-f195.google.com with SMTP id w3so7321240plz.5 for ; Mon, 30 Mar 2020 15:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=s+MoJHMSmcTUpq3uJxnfw8RVUGWalt2lStS+Ah7bIw8=; b=Ycc1KEIOagcHVpqjoqTdfsL8SXZV1i++qn05Rgy8VdmDp72xVkhS8K1vnLdiF6MQc0 LovPWxqrUa8uOtPkhubC5G1/vHnyQgfh1cBs6LjDI96nKCBeQFfiBefGa8f7U2rvOmLp ZIwmTYa3aPwoL47kaUKGGZg+NyJqNd38Fn0GTuWgY1G5XevW7LmlR7EuUCI9Szc91BzI VS7XbAMruSlBt5pELkjNUuSF6lRdHCsM8oRvhlOUysXOf1FdwrXeJA/6wtvo5LUVNRM0 2swl6ETvnTFp0mSnOPaXBFG9pN2iewLiDZutUQn/Uuang/YFqkEpUA47goeAmwJTnqR7 oopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=s+MoJHMSmcTUpq3uJxnfw8RVUGWalt2lStS+Ah7bIw8=; b=NRpa1X+msjuTl7cULaItt0QLXvf6GMOuLU3KDj8E+/glCyK0/d35UFY5Tbe1ISH9XL QlzjFOAE/7W2sAJlHEDO77Swv8bCmd/eBeCAGRAWSDO1McXbW3idLpSMzp05jNOGNDFj 23UJBFuvkd1mxxlkm8Xc9INbzTqL6VJzqvnmmMf3DYEnz1KG0S8y24rX+Don4tYh1kAo G8tKhuTWqT6AHWMmtafA3yaLe8ovrrTLw7zOUHvXSOijT3SUu5Teu6tWmnRRZKGk+NGj r3vh/M/WMdCIn6Gm3ZRDkP+w8q7OB1gIFwvfwCagxAnUec3gh4su5DJkkNzQR++V3zTA 9u+g== X-Gm-Message-State: ANhLgQ38cPQPUfqN4mZNznC0M7ke5pKJMk8KTiloowdpjsS+A3+KdivS zLiLueA9pdXC3y2AKMd6AmQJZyhNIKYnaw== X-Received: by 2002:a17:902:aa97:: with SMTP id d23mr14477810plr.244.1585607166274; Mon, 30 Mar 2020 15:26:06 -0700 (PDT) Received: from OptiPlexFedora ([47.144.161.84]) by smtp.gmail.com with ESMTPSA id c201sm11015633pfc.73.2020.03.30.15.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 15:26:05 -0700 (PDT) Message-ID: <61bb6678d48557895671488357a62680d0ae655f.camel@gmail.com> Subject: Re: [PATCH v6] staging: vt6656: add error code handling to unused variable From: "John B. Wyatt IV" To: Stefano Brivio Cc: outreachy-kernel@googlegroups.com, Julia Lawall , Forest Bond , Greg Kroah-Hartman , Quentin Deslandes , Colin Ian King , Malcolm Priestley , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Date: Mon, 30 Mar 2020 15:26:04 -0700 In-Reply-To: <20200331000143.7c8f98c0@elisabeth> References: <20200330214613.31078-1-jbwyatt4@gmail.com> <20200331000143.7c8f98c0@elisabeth> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-03-31 at 00:01 +0200, Stefano Brivio wrote: > On Mon, 30 Mar 2020 14:46:13 -0700 > "John B. Wyatt IV" wrote: > > > Add error code handling to unused 'ret' variable that was never > > used. > > Return an error code from functions called within > > vnt_radio_power_on. > > > > Issue reported by coccinelle (coccicheck). > > > > Suggested-by: Quentin Deslandes > > Suggested-by: Stefano Brivio > > Reviewed-by: Quentin Deslandes > > Signed-off-by: John B. Wyatt IV > > --- > > v6: Forgot to add all the v5 code to commit. > > > > v5: Remove Suggested-by: Julia Lawall above seperator line. > > Remove break; statement in switch block. > > break; removal checked by both gcc compile and checkpatch. > > Suggested by Stefano Brivio > > > > v4: Move Suggested-by: Julia Lawall above seperator line. > > Add Reviewed-by tag as requested by Quentin Deslandes. > > > > v3: Forgot to add v2 code changes to commit. > > > > v2: Replace goto statements with return. > > Remove last if check because it was unneeded. > > Suggested-by: Julia Lawall > > > > drivers/staging/vt6656/card.c | 20 ++++++++++++-------- > > 1 file changed, 12 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/staging/vt6656/card.c > > b/drivers/staging/vt6656/card.c > > index dc3ab10eb630..c947e8188384 100644 > > --- a/drivers/staging/vt6656/card.c > > +++ b/drivers/staging/vt6656/card.c > > @@ -723,9 +723,13 @@ int vnt_radio_power_on(struct vnt_private > > *priv) > > { > > int ret = 0; > > > > - vnt_exit_deep_sleep(priv); > > + ret = vnt_exit_deep_sleep(priv); > > + if (ret) > > + return ret; > > > > - vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_RXON); > > + ret = vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_RXON); > > + if (ret) > > + return ret; > > > > switch (priv->rf_type) { > > case RF_AL2230: > > @@ -734,14 +738,14 @@ int vnt_radio_power_on(struct vnt_private > > *priv) > > case RF_VT3226: > > case RF_VT3226D0: > > case RF_VT3342A0: > > - vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL, > > - (SOFTPWRCTL_SWPE2 | > > SOFTPWRCTL_SWPE3)); > > - break; > > + ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL, > > + (SOFTPWRCTL_SWPE2 | > > + SOFTPWRCTL_SWPE3)); > > } > > + if (ret) > > + return ret; > > Hmm, sorry, I haven't been clear enough I guess. > > This is what you're doing: > > if rf_type is not in that list: > - set some bits in a register > - did it fail? return > - did it fail? return > ... > > if rf_type is in that list: > - set some bits in a register > - did it fail? return > - set some other bits > - did it fail? return > ... > > Now, the "set some other bits" part is already selected depending on > rf_type. There's no need to check 'ret' otherwise, so you can move > the > return just after setting 'ret', in the switch case. > Thank you for pointing that out Stefano. That would be a serious issue with logic. Just to be sure. Are you looking for this? switch (priv->rf_type) { case RF_AL2230: case RF_AL2230S: case RF_AIROHA7230: case RF_VT3226: case RF_VT3226D0: case RF_VT3342A0: ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); if (ret) return ret; } > With a check, because you don't want to return if ret == 0. > What do you mean exactly by this? The new code should only return a 0 at the end of the function with the vnt_mac_reg_bits_off call.