Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2898835ybb; Mon, 30 Mar 2020 15:34:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsPFsdpf619fVO7132opSL/Ik3aGMHlY0Nf787Cxx5xOM2LFTLlJb3sExhVyFcb8p+SpSr2 X-Received: by 2002:a9d:66d4:: with SMTP id t20mr10718418otm.275.1585607641257; Mon, 30 Mar 2020 15:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585607641; cv=none; d=google.com; s=arc-20160816; b=xwpvEeTEGrle0uW84AAculsfHRrZaGM8MHbo/0oN2hpjA69d6Y1F7g7QmwF48nVXkd 0sUk8NGTwWHojhWRYWLZvBFvxinaajcG+uXmjregYHn72e/E4lMZil5Z+Oi8N6So1rD9 CxI26XWAzI+JQeZzoE7BpoBX3rWhHioJ7dOZ0/uOcdgmbBCKYBtKve1gDajHKs+huX/o QfyKRYKuxXQ3GBwzqrFocmTZfXRk/FrwITVuP0CgN9w9ZPE0qTIz+WGq77IfdKvaXWzM Y8GKWYPOZhptCSCXK8cHcDLseLq3Q/CGvy5dqsOH4OR+pz6d49bI5SP30xMR78829IrK UhTg== 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=jvgEeFjtAh1QWGoc60hjoonPbLbA3KJyXugPITzRpSc=; b=dHYbkg9DL71woj76z1rkIkZgylbOw0FyqbQ2gbBPHLP4OkxRVTZJeChVlb/sexbQtG bI3PNqrIU96lEluvldEdrE6QG0MBmr/tEcwYXJkTG7NspZ7x2rU8mgJUhhEkMmcB20g6 u6P5XbtUliOe0QVVjcVcCGBNNo8VEwa6vE/lNT9/mqVYJGDSg/itGJra3zBtrIh57L0e 3IOzilR9zjTbXYMpY8P0KTEq6lm1Hd2cRSPC9mlpDi42fCHFLiBwy6naJZkQwQ3WneXa fR+A1WYWkoYccsWXGiumennxOTZW0d7O8BOqu2080yxgSYRmkW87ZIpNf4ExOTj1aZni B4Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TO2rHneN; 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 b197si6207243oii.198.2020.03.30.15.33.49; Mon, 30 Mar 2020 15:34:01 -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=TO2rHneN; 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 S1729867AbgC3WdC (ORCPT + 99 others); Mon, 30 Mar 2020 18:33:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:54873 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729146AbgC3WdC (ORCPT ); Mon, 30 Mar 2020 18:33:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585607581; 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=jvgEeFjtAh1QWGoc60hjoonPbLbA3KJyXugPITzRpSc=; b=TO2rHneNS0KldRS8OU0qcU+Sn/kI84AinnqDjAXFkuo1piq0mPCEHXijW12iab9kbTBTsO 5SSHuYFEDAM2/51/BWDMhF5Klz1jMYcyhLbK1fx3VJMSTJC8fixxJ2VA86Hx2413Aqg/8N JOr8m8luKB8/yIVrClA8L2gvaXfyIhU= 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-144-rmPQzsmXOOCvOv3gMS0LeA-1; Mon, 30 Mar 2020 18:32:57 -0400 X-MC-Unique: rmPQzsmXOOCvOv3gMS0LeA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5B86800D50; Mon, 30 Mar 2020 22:32:55 +0000 (UTC) Received: from elisabeth (unknown [10.36.110.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D13996EFA4; Mon, 30 Mar 2020 22:32:51 +0000 (UTC) Date: Tue, 31 Mar 2020 00:32:44 +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: [PATCH v6] staging: vt6656: add error code handling to unused variable Message-ID: <20200331003244.4e9f5ce2@elisabeth> In-Reply-To: <61bb6678d48557895671488357a62680d0ae655f.camel@gmail.com> References: <20200330214613.31078-1-jbwyatt4@gmail.com> <20200331000143.7c8f98c0@elisabeth> <61bb6678d48557895671488357a62680d0ae655f.camel@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.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Mar 2020 15:26:04 -0700 "John B. Wyatt IV" wrote: > 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; > } Exactly. > > With a check, because you don't want to return if ret == 0. > > > > What do you mean exactly by this? Exactly what you wrote above: if (ret) ... > The new code should only return a 0 at the end of the function with the > vnt_mac_reg_bits_off call. That, or an error code if vnt_mac_reg_bits_off() fails. -- Stefano