Linux-NFS Archive on lore.kernel.org
 help / Atom feed
* [PATCH net-next] svcrdma: Fix an uninitialized variable false warning
@ 2018-12-20  9:49 YueHaibing
  2018-12-28 15:36 ` Chuck Lever
  0 siblings, 1 reply; 3+ messages in thread
From: YueHaibing @ 2018-12-20  9:49 UTC (permalink / raw)
  To: davem, bfields, jlayton, trond.myklebust, anna.schumaker
  Cc: linux-kernel, netdev, linux-nfs, jgg, chuck.lever, bvanassche,
	YueHaibing

smatch warning this:
net/sunrpc/xprtrdma/svc_rdma_rw.c:351 svc_rdma_post_chunk_ctxt() error: uninitialized symbol 'bad_wr'
net/sunrpc/xprtrdma/verbs.c:1569 rpcrdma_post_recvs() error: uninitialized symbol 'bad_wr'

'bad_wr' is initialized in ib_post_send. But smatch
doesn't know that and warns this.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +-
 net/sunrpc/xprtrdma/verbs.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
index dc19517..0954b25 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
@@ -308,7 +308,7 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
 	struct svcxprt_rdma *rdma = cc->cc_rdma;
 	struct svc_xprt *xprt = &rdma->sc_xprt;
 	struct ib_send_wr *first_wr;
-	const struct ib_send_wr *bad_wr;
+	const struct ib_send_wr *bad_wr = NULL;
 	struct list_head *tmp;
 	struct ib_cqe *cqe;
 	int ret;
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 3ddba94..37be70f 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1518,7 +1518,7 @@ void
 rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
 {
 	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
-	struct ib_recv_wr *wr, *bad_wr;
+	struct ib_recv_wr *wr, *bad_wr = NULL;
 	int needed, count, rc;
 
 	rc = 0;
-- 
2.7.0



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

* Re: [PATCH net-next] svcrdma: Fix an uninitialized variable false warning
  2018-12-20  9:49 [PATCH net-next] svcrdma: Fix an uninitialized variable false warning YueHaibing
@ 2018-12-28 15:36 ` Chuck Lever
  2019-01-03 17:41   ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: Chuck Lever @ 2018-12-28 15:36 UTC (permalink / raw)
  To: YueHaibing, Bart Van Assche
  Cc: David S. Miller, Bruce Fields, Jeff Layton, Trond Myklebust,
	Anna Schumaker, open list, netdev, Linux NFS Mailing List,
	Jason Gunthorpe


> On Dec 20, 2018, at 4:49 AM, YueHaibing <yuehaibing@huawei.com> wrote:
> 
> smatch warning this:
> net/sunrpc/xprtrdma/svc_rdma_rw.c:351 svc_rdma_post_chunk_ctxt() error: uninitialized symbol 'bad_wr'
> net/sunrpc/xprtrdma/verbs.c:1569 rpcrdma_post_recvs() error: uninitialized symbol 'bad_wr'
> 
> 'bad_wr' is initialized in ib_post_send. But smatch
> doesn't know that and warns this.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +-
> net/sunrpc/xprtrdma/verbs.c       | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> index dc19517..0954b25 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> @@ -308,7 +308,7 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
> 	struct svcxprt_rdma *rdma = cc->cc_rdma;
> 	struct svc_xprt *xprt = &rdma->sc_xprt;
> 	struct ib_send_wr *first_wr;
> -	const struct ib_send_wr *bad_wr;
> +	const struct ib_send_wr *bad_wr = NULL;
> 	struct list_head *tmp;
> 	struct ib_cqe *cqe;
> 	int ret;
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 3ddba94..37be70f 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -1518,7 +1518,7 @@ void
> rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
> {
> 	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
> -	struct ib_recv_wr *wr, *bad_wr;
> +	struct ib_recv_wr *wr, *bad_wr = NULL;
> 	int needed, count, rc;
> 
> 	rc = 0;
> -- 
> 2.7.0

Does this need

Fixes: d34ac5cd3a73 ("RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const")  ???

Bart, any comments?


--
Chuck Lever




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

* Re: [PATCH net-next] svcrdma: Fix an uninitialized variable false warning
  2018-12-28 15:36 ` Chuck Lever
@ 2019-01-03 17:41   ` Bart Van Assche
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2019-01-03 17:41 UTC (permalink / raw)
  To: Chuck Lever, YueHaibing
  Cc: David S. Miller, Bruce Fields, Jeff Layton, Trond Myklebust,
	Anna Schumaker, open list, netdev, Linux NFS Mailing List,
	Jason Gunthorpe

On Fri, 2018-12-28 at 10:36 -0500, Chuck Lever wrote:
+AD4 +AD4 On Dec 20, 2018, at 4:49 AM, YueHaibing +ADw-yuehaibing+AEA-huawei.com+AD4 wrote:
+AD4 +AD4 
+AD4 +AD4 smatch warning this:
+AD4 +AD4 net/sunrpc/xprtrdma/svc+AF8-rdma+AF8-rw.c:351 svc+AF8-rdma+AF8-post+AF8-chunk+AF8-ctxt() error: uninitialized symbol 'bad+AF8-wr'
+AD4 +AD4 net/sunrpc/xprtrdma/verbs.c:1569 rpcrdma+AF8-post+AF8-recvs() error: uninitialized symbol 'bad+AF8-wr'
+AD4 +AD4 
+AD4 +AD4 'bad+AF8-wr' is initialized in ib+AF8-post+AF8-send. But smatch
+AD4 +AD4 doesn't know that and warns this.
+AD4 +AD4 
+AD4 +AD4 Signed-off-by: YueHaibing +ADw-yuehaibing+AEA-huawei.com+AD4
+AD4 +AD4 ---
+AD4 +AD4 net/sunrpc/xprtrdma/svc+AF8-rdma+AF8-rw.c +AHw 2 +--
+AD4 +AD4 net/sunrpc/xprtrdma/verbs.c       +AHw 2 +--
+AD4 +AD4 2 files changed, 2 insertions(+-), 2 deletions(-)
+AD4 +AD4 
+AD4 +AD4 diff --git a/net/sunrpc/xprtrdma/svc+AF8-rdma+AF8-rw.c b/net/sunrpc/xprtrdma/svc+AF8-rdma+AF8-rw.c
+AD4 +AD4 index dc19517..0954b25 100644
+AD4 +AD4 --- a/net/sunrpc/xprtrdma/svc+AF8-rdma+AF8-rw.c
+AD4 +AD4 +-+-+- b/net/sunrpc/xprtrdma/svc+AF8-rdma+AF8-rw.c
+AD4 +AD4 +AEAAQA -308,7 +-308,7 +AEAAQA static int svc+AF8-rdma+AF8-post+AF8-chunk+AF8-ctxt(struct svc+AF8-rdma+AF8-chunk+AF8-ctxt +ACo-cc)
+AD4 +AD4 	struct svcxprt+AF8-rdma +ACo-rdma +AD0 cc-+AD4-cc+AF8-rdma+ADs
+AD4 +AD4 	struct svc+AF8-xprt +ACo-xprt +AD0 +ACY-rdma-+AD4-sc+AF8-xprt+ADs
+AD4 +AD4 	struct ib+AF8-send+AF8-wr +ACo-first+AF8-wr+ADs
+AD4 +AD4 -	const struct ib+AF8-send+AF8-wr +ACo-bad+AF8-wr+ADs
+AD4 +AD4 +-	const struct ib+AF8-send+AF8-wr +ACo-bad+AF8-wr +AD0 NULL+ADs
+AD4 +AD4 	struct list+AF8-head +ACo-tmp+ADs
+AD4 +AD4 	struct ib+AF8-cqe +ACo-cqe+ADs
+AD4 +AD4 	int ret+ADs
+AD4 +AD4 diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
+AD4 +AD4 index 3ddba94..37be70f 100644
+AD4 +AD4 --- a/net/sunrpc/xprtrdma/verbs.c
+AD4 +AD4 +-+-+- b/net/sunrpc/xprtrdma/verbs.c
+AD4 +AD4 +AEAAQA -1518,7 +-1518,7 +AEAAQA void
+AD4 +AD4 rpcrdma+AF8-post+AF8-recvs(struct rpcrdma+AF8-xprt +ACo-r+AF8-xprt, bool temp)
+AD4 +AD4 +AHs
+AD4 +AD4 	struct rpcrdma+AF8-buffer +ACo-buf +AD0 +ACY-r+AF8-xprt-+AD4-rx+AF8-buf+ADs
+AD4 +AD4 -	struct ib+AF8-recv+AF8-wr +ACo-wr, +ACo-bad+AF8-wr+ADs
+AD4 +AD4 +-	struct ib+AF8-recv+AF8-wr +ACo-wr, +ACo-bad+AF8-wr +AD0 NULL+ADs
+AD4 +AD4 	int needed, count, rc+ADs
+AD4 +AD4 
+AD4 +AD4 	rc +AD0 0+ADs
+AD4 +AD4 -- 
+AD4 +AD4 2.7.0
+AD4 
+AD4 Does this need
+AD4 
+AD4 Fixes: d34ac5cd3a73 (+ACI-RDMA, core and ULPs: Declare ib+AF8-post+AF8-send() and ib+AF8-post+AF8-recv() arguments const+ACI)  ???
+AD4 
+AD4 Bart, any comments?

Hi Chuck,

My understanding is that the +ACI-Fixes:+ACI tag should only be used for patches
that fix bugs. Since this patch addresses a false positive warning reported
by smatch I think that it would be misleading to use the +ACI-Fixes:+ACI tag.
Before proceeding with this patch, I think that smatch should be improved.
The following patch namely was not sufficient to suppress the xprtrdma
warning reported by smatch:

diff --git a/include/rdma/ib+AF8-verbs.h b/include/rdma/ib+AF8-verbs.h
index a3ceed3a040a..498eaa245d1a 100644
--- a/include/rdma/ib+AF8-verbs.h
+-+-+- b/include/rdma/ib+AF8-verbs.h
+AEAAQA -3327,9 +-3327,16 +AEAAQA static inline int ib+AF8-post+AF8-srq+AF8-recv(struct ib+AF8-srq +ACo-srq,
 				   const struct ib+AF8-recv+AF8-wr +ACoAKg-bad+AF8-recv+AF8-wr)
 +AHs
 	const struct ib+AF8-recv+AF8-wr +ACo-dummy+ADs
-
-	return srq-+AD4-device-+AD4-ops.post+AF8-srq+AF8-recv(srq, recv+AF8-wr,
-					      bad+AF8-recv+AF8-wr ? : +ACY-dummy)+ADs
+-	int ret+ADs
+-
+-	ret +AD0 srq-+AD4-device-+AD4-ops.post+AF8-srq+AF8-recv(srq, recv+AF8-wr,
+-					     bad+AF8-recv+AF8-wr ? : +ACY-dummy)+ADs
+-+ACM-ifdef +AF8AXw-CHECKER+AF8AXw
+-	/+ACo Tell static analyzers that +ACo-bad+AF8-send+AF8-wr is initialized if ret +ACEAPQ 0 +ACo-/
+-	if (ret +ACYAJg bad+AF8-send+AF8-wr)
+-		+ACo-bad+AF8-send+AF8-wr +AD0 +ACo-bad+AF8-send+AF8-wr+ADs
+-+ACM-endif
+-	return ret+ADs
 +AH0
 
 /+ACoAKg
+AEAAQA -3431,8 +-3438,15 +AEAAQA static inline int ib+AF8-post+AF8-send(struct ib+AF8-qp +ACo-qp,
 			       const struct ib+AF8-send+AF8-wr +ACoAKg-bad+AF8-send+AF8-wr)
 +AHs
 	const struct ib+AF8-send+AF8-wr +ACo-dummy+ADs
+-	int ret+ADs
 
-	return qp-+AD4-device-+AD4-ops.post+AF8-send(qp, send+AF8-wr, bad+AF8-send+AF8-wr ? : +ACY-dummy)+ADs
+-	ret +AD0 qp-+AD4-device-+AD4-ops.post+AF8-send(qp, send+AF8-wr, bad+AF8-send+AF8-wr ? : +ACY-dummy)+ADs
+-+ACM-ifdef +AF8AXw-CHECKER+AF8AXw
+-	/+ACo Tell static analyzers that +ACo-bad+AF8-send+AF8-wr is initialized if ret +ACEAPQ 0 +ACo-/
+-	if (ret +ACYAJg bad+AF8-send+AF8-wr)
+-		+ACo-bad+AF8-send+AF8-wr +AD0 +ACo-bad+AF8-send+AF8-wr+ADs
+-+ACM-endif
+-	return ret+ADs
 +AH0
 
 /+ACoAKg
+AEAAQA -3448,8 +-3462,15 +AEAAQA static inline int ib+AF8-post+AF8-recv(struct ib+AF8-qp +ACo-qp,
 			       const struct ib+AF8-recv+AF8-wr +ACoAKg-bad+AF8-recv+AF8-wr)
 +AHs
 	const struct ib+AF8-recv+AF8-wr +ACo-dummy+ADs
+-	int ret+ADs
 
-	return qp-+AD4-device-+AD4-ops.post+AF8-recv(qp, recv+AF8-wr, bad+AF8-recv+AF8-wr ? : +ACY-dummy)+ADs
+-	ret +AD0 qp-+AD4-device-+AD4-ops.post+AF8-recv(qp, recv+AF8-wr, bad+AF8-recv+AF8-wr ? : +ACY-dummy)+ADs
+-+ACM-ifdef +AF8AXw-CHECKER+AF8AXw
+-	/+ACo Tell static analyzers that +ACo-bad+AF8-send+AF8-wr is initialized if ret +ACEAPQ 0 +ACo-/
+-	if (ret +ACYAJg bad+AF8-send+AF8-wr)
+-		+ACo-bad+AF8-send+AF8-wr +AD0 +ACo-bad+AF8-send+AF8-wr+ADs
+-+ACM-endif
+-	return ret+ADs
 +AH0
 
 struct ib+AF8-cq +ACoAXwBf-ib+AF8-alloc+AF8-cq(struct ib+AF8-device +ACo-dev, void +ACo-private,

Bart.

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20  9:49 [PATCH net-next] svcrdma: Fix an uninitialized variable false warning YueHaibing
2018-12-28 15:36 ` Chuck Lever
2019-01-03 17:41   ` Bart Van Assche

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org linux-nfs@archiver.kernel.org
	public-inbox-index linux-nfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox