From: Arnd Bergmann <arnd@arndb.de>
To: Dennis Dalessandro <dennis.dalessandro@intel.com>,
Mike Marciniszyn <mike.marciniszyn@intel.com>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>
Cc: Arnd Bergmann <arnd@arndb.de>,
Kamenee Arumugam <kamenee.arumugam@intel.com>,
Jason Gunthorpe <jgg@mellanox.com>,
Shamir Rabinovitch <shamir.rabinovitch@oracle.com>,
Gal Pressman <galpress@amazon.com>,
Leon Romanovsky <leon@kernel.org>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
clang-built-linux@googlegroups.com
Subject: [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable
Date: Wed, 10 Jul 2019 15:07:51 +0200 [thread overview]
Message-ID: <20190710130802.1878874-1-arnd@arndb.de> (raw)
As clang reports, rvt_create_cq() may return an uninitialized
variable, because the 'err' variable is shadowed by another
local declaration:
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
I can't think of any reason for the inner variable declaration, so
remove it to avoid the issue.
Fixes: 239b0e52d8aa ("IB/hfi1: Move rvt_cq_wc struct into uapi directory")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
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.20.0
next reply other threads:[~2019-07-10 13:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 13:07 Arnd Bergmann [this message]
2019-07-10 16:54 ` [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable Marciniszyn, Mike
2019-07-10 16:58 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190710130802.1878874-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=dennis.dalessandro@intel.com \
--cc=dledford@redhat.com \
--cc=galpress@amazon.com \
--cc=jgg@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=kamenee.arumugam@intel.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mike.marciniszyn@intel.com \
--cc=shamir.rabinovitch@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox