Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9486443ybi; Wed, 10 Jul 2019 11:07:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1dhe9mZL/VY+4XEfe2NhR7WrHc7HnNykq0Gezh9dVDIioNMr2YJPgg1ag+CCISAGbuE0C X-Received: by 2002:a63:f807:: with SMTP id n7mr39651276pgh.119.1562782075296; Wed, 10 Jul 2019 11:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562782075; cv=none; d=google.com; s=arc-20160816; b=dJXS9JR40+bDOk+C24QtpkV8cFcuwrVp9r89OFVxUr+DwlsjtWoVh+VaaiPCjDzJRB 3+KhfVZfD5OQTpw+0y6TMc6j2w9NUxTj5YTZfM8TudSHhvj6mgfZT5pLamQPetZf/7p8 Pv4Iu8EUViaSXzdu6U6W2mYsmPXQr4c7sMXOCqnr5EajchKu9OEP2+G8Qpp+dZ9zYrN0 nVi7tBHRR/zTxVZ+GwHrm9wF1dtiaNEOq0DONoQI/raZ0eZYEj7jv+s5anYx9drqYy3B GEKZ4Dq7atfSZg/deWHnce60m3W1KDwdNDxqKHVIb6Fs0GXFywDEftaKhpj2vH9WX6qT Aetw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=dCTZSq4b8FNjsHvpAuA3DflO6XPO9Y51CMoamLGMSTU=; b=QJ+SAGLDFPk0AgyH/Ch4XEOGdHlHKH6hoGlYnxYfYqE7FDAUrbEi79FYun8WYhjWZ2 b6XrlLY+IbYh3WMJNsqatTFfZdppnxdCbi3ookTeOn/0TU/Hzyu0C/UV+nQ0kh6V36+O eMeVgtbPOml4jFdkvewSeKvoLS+6L1stHntsAjwQFrp3eB6diNAj7keW5miSOfNJIWyR 3+VUSDC1/3OD9AqcSKi3kq58ldMig4H7+BSgg1qx1MPOFMpIfr3ARXuPFAjkBhaK/sPT ffGS69v0MaIcNgq4soqSv58caaV8QysGAwrO5aqZzeoPq+TXclsCmkangCtUoPcubZvH uUkA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si2582374pgp.424.2019.07.10.11.07.39; Wed, 10 Jul 2019 11:07:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727928AbfGJRDZ (ORCPT + 99 others); Wed, 10 Jul 2019 13:03:25 -0400 Received: from mga07.intel.com ([134.134.136.100]:17215 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727463AbfGJRDY (ORCPT ); Wed, 10 Jul 2019 13:03:24 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2019 10:03:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,475,1557212400"; d="scan'208";a="176899411" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by orsmga002.jf.intel.com with ESMTP; 10 Jul 2019 10:03:23 -0700 Date: Wed, 10 Jul 2019 10:03:23 -0700 From: Ira Weiny To: Nathan Chancellor Cc: Dennis Dalessandro , Mike Marciniszyn , Doug Ledford , Jason Gunthorpe , Kamenee Arumugam , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nick Desaulniers Subject: Re: [PATCH v2] IB/rdmavt: Fix variable shadowing issue in rvt_create_cq Message-ID: <20190710170322.GA5072@iweiny-DESK2.sc.intel.com> References: <20190709221312.7089-1-natechancellor@gmail.com> <20190709230552.61842-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190709230552.61842-1-natechancellor@gmail.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 09, 2019 at 04:05:53PM -0700, Nathan Chancellor wrote: > clang warns: > > drivers/infiniband/sw/rdmavt/cq.c:260:7: warning: variable 'err' is used > uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (err) > ^~~ > drivers/infiniband/sw/rdmavt/cq.c:310:9: note: uninitialized use occurs > here > return err; > ^~~ > drivers/infiniband/sw/rdmavt/cq.c:260:3: note: remove the 'if' if its > condition is always false > if (err) > ^~~~~~~~ > drivers/infiniband/sw/rdmavt/cq.c:253:7: warning: variable 'err' is used > uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (!cq->ip) { > ^~~~~~~ > drivers/infiniband/sw/rdmavt/cq.c:310:9: note: uninitialized use occurs > here > return err; > ^~~ > drivers/infiniband/sw/rdmavt/cq.c:253:3: note: remove the 'if' if its > condition is always false > if (!cq->ip) { > ^~~~~~~~~~~~~~ > drivers/infiniband/sw/rdmavt/cq.c:211:9: note: initialize the variable > 'err' to silence this warning > int err; > ^ > = 0 > 2 warnings generated. What version of the kernel was this found on? I don't see the problem with 5.2. AFAICS there is no 'err' in the function scope and the if scoped 'err' is initialized properly on line 239. Ira > > The function scoped err variable is uninitialized when the flow jumps > into the if statement. The if scoped err variable shadows the function > scoped err variable, preventing the err assignments within the if > statement to be reflected at the function level, which will cause > uninitialized use when the goto statements are taken. > > Just remove the if scoped err declaration so that there is only one > copy of the err variable for this function. > > Fixes: 239b0e52d8aa ("IB/hfi1: Move rvt_cq_wc struct into uapi directory") > Link: https://github.com/ClangBuiltLinux/linux/issues/594 > Reviewed-by: Nick Desaulniers > Signed-off-by: Nathan Chancellor > --- > > v1 -> v2: > > * Updated the wording of the commit message to use proper terms like > scoping and shadowing, thanks to review from Nick (let me know if the > wording isn't up to snuff). > > drivers/infiniband/sw/rdmavt/cq.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/infiniband/sw/rdmavt/cq.c b/drivers/infiniband/sw/rdmavt/cq.c > index fac87b13329d..a85571a4cf57 100644 > --- a/drivers/infiniband/sw/rdmavt/cq.c > +++ b/drivers/infiniband/sw/rdmavt/cq.c > @@ -247,8 +247,6 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, > * See rvt_mmap() for details. > */ > if (udata && udata->outlen >= sizeof(__u64)) { > - int err; > - > cq->ip = rvt_create_mmap_info(rdi, sz, udata, u_wc); > if (!cq->ip) { > err = -ENOMEM; > -- > 2.22.0 >