Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2876895ybb; Mon, 30 Mar 2020 15:04:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuBDQ3+BaobKLlD4wKVG9OJbHCGZ9U9LZDqGliFORJ/QrBdseWpvZMeO9aoCmbIIi9iKyPg X-Received: by 2002:a05:6830:15c2:: with SMTP id j2mr10216979otr.107.1585605842481; Mon, 30 Mar 2020 15:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585605842; cv=none; d=google.com; s=arc-20160816; b=kBfFEKL4OwkhGm7r0ttEmSG7LrtRA/ccdAuD5LF2wNtQwofAQ5CGORpPhF1UyztDrs lY/4VvGzYF8c98+yQ5UZTd1D6R4aMijSx4OIaJDIkpMfu033AProYQUwbXxuGV3XdeQg 2q5/8bxLjmmX+52N3hvu8IllYFivwBWG2AhsLJoQlgcwmkgiJ/B7ccn7Ev/xc5hV9RU/ cR1Cp/uOBjXZ6iXoAMiaVb2NBdMCB9QTQJQNfaDl/KZfx+szAjuq397Ct69Rzfgeweqe D4mV8qO7PkT7R9gtVNw+EkWaWmOGD7IPSCvgGmlWnfhZCxKZeVZC+ZThs5C7KvFMgSUf dqQg== 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=76G6LlH/Kp/jbMcwi/Y+VgqRenjpbmM+ChfO2SMexeY=; b=R8S2Qy6QhzOZ7tI7Cv1O9RDqK/5Wo9X1MYmcHXbrcNDdu0Pxrd2IjFE5EEH7OHyR+h 37CuF7N1VQnKEsRhNDXzJGvC6Q2Wtr2XvbXl9cAiW8gYSDgIppCNjhmOTMwKK3bTrLep NDp1H3+bK/ohtAydOZJqN6gSgyHon/Au3EvvY6Qet7qB1MlEWWixoIBt3o8my3MfIa6k NkNNuje6qzW6X/mbqv2Wmiuh4l9WtbV0cHVdZen4eP6GzMAoYsgIknOrFmZSq7LOOs09 WHlReDohLZAiDjMyJxcmvRKnR+Xod2yEQDFMynI2FVdbb2hQatr5l9lfL73qBTuV6oku TgOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PbbwkAbo; 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 r71si6323116oie.265.2020.03.30.15.03.38; Mon, 30 Mar 2020 15:04:02 -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=PbbwkAbo; 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 S1730808AbgC3WCC (ORCPT + 99 others); Mon, 30 Mar 2020 18:02:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:46673 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730794AbgC3WCB (ORCPT ); Mon, 30 Mar 2020 18:02:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585605720; 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=76G6LlH/Kp/jbMcwi/Y+VgqRenjpbmM+ChfO2SMexeY=; b=PbbwkAboPvKR/+SvW0QY5EwsbmDdFcmj3CwYIeKsv1Op4hSDSK96LYASHo9hz0BBjJQl4R MSogi0f6LW76/jCdUgWiBh/aCa6dI+dAeTUoDGJZKwXS3kW9ol8sLhx55DDxieB5oy9md3 W++/0VkQ5WIpUkXIN3YpMfC+LvF9YhA= 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-94-jPU1WqcjOQW_wyZ-dNY98A-1; Mon, 30 Mar 2020 18:01:59 -0400 X-MC-Unique: jPU1WqcjOQW_wyZ-dNY98A-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 85435107ACC4; Mon, 30 Mar 2020 22:01:57 +0000 (UTC) Received: from elisabeth (unknown [10.36.110.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1888F96B60; Mon, 30 Mar 2020 22:01:51 +0000 (UTC) Date: Tue, 31 Mar 2020 00:01:43 +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: <20200331000143.7c8f98c0@elisabeth> In-Reply-To: <20200330214613.31078-1-jbwyatt4@gmail.com> References: <20200330214613.31078-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.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 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. With a check, because you don't want to return if ret == 0. -- Stefano