Re: [PATCH net-next] svcrdma: Fix an uninitialized variable false warning

From: Bart Van Assche
Date: Thu Jan 03 2019 - 12:41:13 EST


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.