Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2660263ybb; Mon, 30 Mar 2020 10:22:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs4bq8xWNnqmkiQIQt14iSMR5+OAqYkCS7WaWBb4o92LPE5gn6odD/86SNah+XRVH3Ps6hR X-Received: by 2002:a9d:748a:: with SMTP id t10mr5552246otk.244.1585588952594; Mon, 30 Mar 2020 10:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585588952; cv=none; d=google.com; s=arc-20160816; b=Ml9vA2lpYH12IuMTYIX6Nlp/2JHC7IeldeUBi0PZNJOJrXbR3JJDG9kU3ns9H2Rp1w GHtM5s6b44UX2An/KNTtfpdIhC1PPD3Ykt49ACtJ5R/BJcvo/Z1IHpSBeQdxZw+xWCe5 eYXBhv2m2eeFs/A6A19NGMhQqZ4sLAzyuLPaiUFcvBd9gyzXDhgr0UuKOvFhZwwD2K2p HqcW50sx9Pn4jC4TLqZfsDILvlweoxgAW1MxXq0X6RxUuy8LVselEpKMvvJtaFqjMkiM 4fDR32MCruSV8rdwRK2RxLSRRaOTDI5H6MZR7hj8ODn5Q5EJqcCz0VhOhgnGxTv/X2y8 x2dw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=OVuub6JvUfi96XLhyjTFYsOF46LcBuVZlqMIFo1MoSI=; b=PjuEbLrjtkCvTxs7yDMnKTzPcHgQWa1QNehJke1RzAAFW3eGwGA9c0kdBkg403l9sr jQlrorskl676aV+JbI/CUDMZwA1OUfaqOqZUfI7ipxIUMtnEGo0u+XBBT4a6KKp4uIYq b2By/Ahp+Qp3Labhbdehf+cynVL7Hh4JEVUByrfRcQsOy3KOvoDaRPfODokTpyXHK0wK wcdSWkqAHi8bAkwt9ZXfnnoSM4MTBKKZYEFWATVEzdHOclvg25RvTkW6RcDjym24wkQX D4XLHhggaOkG5giF3SQyPZ7KvUohidO/+xla3MhqXNAaYmnTO+2TUsGUeFRfwrUNYUkJ Sp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ml8+pFE4; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t83si6243011oig.239.2020.03.30.10.22.19; Mon, 30 Mar 2020 10:22:32 -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=@redhat.com header.s=mimecast20190719 header.b=Ml8+pFE4; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728948AbgC3RPI (ORCPT + 99 others); Mon, 30 Mar 2020 13:15:08 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:28931 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgC3RPI (ORCPT ); Mon, 30 Mar 2020 13:15:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585588507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OVuub6JvUfi96XLhyjTFYsOF46LcBuVZlqMIFo1MoSI=; b=Ml8+pFE4jDA+wLHq48LOK6tJKXQUaYZenYGC5k3ZQ9HoT3KLph0LGUPurjJGun7MPnwJN5 HAtZA2Xqi4cXshU/uqDeIQEtyoErMcwHr+pAEoykqsBhLEdInwBSO+wMQ1Iqylu5PiwLOU lZofQ2ni+gNyP/dGnkV27CHFiKJSAgM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-dH9LHYWXOq28ZFMRDrrxlA-1; Mon, 30 Mar 2020 13:15:03 -0400 X-MC-Unique: dH9LHYWXOq28ZFMRDrrxlA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1691E149C1; Mon, 30 Mar 2020 17:14:54 +0000 (UTC) Received: from elisabeth (unknown [10.36.110.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A17195C1B5; Mon, 30 Mar 2020 17:14:47 +0000 (UTC) Date: Mon, 30 Mar 2020 19:14:39 +0200 From: Stefano Brivio To: "John B. Wyatt IV" 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 Subject: Re: [Outreachy kernel] [PATCH v4] staging: vt6656: add error code handling to unused variable Message-ID: <20200330191439.3bfcb658@elisabeth> In-Reply-To: <20200330164530.2919-1-jbwyatt4@gmail.com> References: <20200330164530.2919-1-jbwyatt4@gmail.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Mar 2020 09:45:30 -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 > Suggested-by: Julia Lawall > Reviewed-by: Quentin Deslandes > Signed-off-by: John B. Wyatt IV > --- > v4: Move Suggested-by: Julia Lawall above seperator line. Actually, as Julia didn't suggest this patch, the place where you had this in v3 was the right one. > Add Reviewed-by tag as requested by Quentin Deslandes. > Suggested-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 | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c > index dc3ab10eb630..239012539e73 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)); > + ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL, > + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); Note that you broke the alignment here: the ( should be aligned with 'priv'. By the way, those parentheses are useless, but it's not something you should fix in this patch. > break; Unless gcc whines (or checkpatch, even), you could replace this break by the if (ret) return ret; below. If some tool is not happy with this, though, you should still move that here: ret will be checked only for those values of 'rf_type'. > } > + if (ret) > + return ret; Another thing that should be considered in this function is to restore the previous hardware state on failures, but I think the way you're handling this is possibly the safest, without hardware to test on. -- Stefano