linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable
@ 2019-07-10 13:07 Arnd Bergmann
  2019-07-10 16:54 ` Marciniszyn, Mike
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-07-10 13:07 UTC (permalink / raw)
  To: Dennis Dalessandro, Mike Marciniszyn, Doug Ledford, Jason Gunthorpe
  Cc: Arnd Bergmann, Kamenee Arumugam, Jason Gunthorpe,
	Shamir Rabinovitch, Gal Pressman, Leon Romanovsky, linux-rdma,
	linux-kernel, clang-built-linux

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable
  2019-07-10 13:07 [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable Arnd Bergmann
@ 2019-07-10 16:54 ` Marciniszyn, Mike
  2019-07-10 16:58   ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Marciniszyn, Mike @ 2019-07-10 16:54 UTC (permalink / raw)
  To: Arnd Bergmann, Dalessandro, Dennis, Doug Ledford, Jason Gunthorpe
  Cc: Arumugam, Kamenee, Jason Gunthorpe, Shamir Rabinovitch,
	Gal Pressman, Leon Romanovsky, linux-rdma, linux-kernel,
	clang-built-linux

> Subject: [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable
> 
> I can't think of any reason for the inner variable declaration, so
> remove it to avoid the issue.
> 

I agree!

> Fixes: 239b0e52d8aa ("IB/hfi1: Move rvt_cq_wc struct into uapi directory")

Thanks for catching this!

Acked-by: Mike Marciniszyn <mike.marciniszyn@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable
  2019-07-10 16:54 ` Marciniszyn, Mike
@ 2019-07-10 16:58   ` Jason Gunthorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2019-07-10 16:58 UTC (permalink / raw)
  To: Marciniszyn, Mike
  Cc: Arnd Bergmann, Dalessandro, Dennis, Doug Ledford, Arumugam,
	Kamenee, Shamir Rabinovitch, Gal Pressman, Leon Romanovsky,
	linux-rdma, linux-kernel, clang-built-linux

On Wed, Jul 10, 2019 at 04:54:33PM +0000, Marciniszyn, Mike wrote:
> > Subject: [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable
> > 
> > I can't think of any reason for the inner variable declaration, so
> > remove it to avoid the issue.
> > 
> 
> I agree!
> 
> > Fixes: 239b0e52d8aa ("IB/hfi1: Move rvt_cq_wc struct into uapi directory")
> 
> Thanks for catching this!
> 
> Acked-by: Mike Marciniszyn <mike.marciniszyn@intel.com>

Thanks, I'm going to take Nathan's identical patch though, it arrived
first

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-10 16:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10 13:07 [PATCH] [net-next] IB/hfi1: removed shadowed 'err' variable Arnd Bergmann
2019-07-10 16:54 ` Marciniszyn, Mike
2019-07-10 16:58   ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).