diff mbox series

[rdma-core,2/5] libhns: Fix errors detected by Cppcheck tool

Message ID 1550307813-151285-3-git-send-email-oulijun@huawei.com (mailing list archive)
State Superseded
Headers show
Series Misc updates for libhns | expand

Commit Message

Lijun Ou Feb. 16, 2019, 9:03 a.m. UTC
From: chenglang <chenglang@huawei.com>

The driver passes structure resp's member a to ib core.
Then, ib core uses container_of() to init resp's all
members. At last, the driver uses resp's member b. The
static check tool CppCheck considers this is an uninitStructMember
bug. Here initialize resp in the driver to avoid this dependence.

Signed-off-by: chenglang <chenglang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 providers/hns/hns_roce_u.c       | 2 +-
 providers/hns/hns_roce_u_verbs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index 8113c00..15e52f6 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -92,7 +92,7 @@  static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
 	struct ibv_get_context cmd;
 	struct ibv_device_attr dev_attrs;
 	struct hns_roce_context *context;
-	struct hns_roce_alloc_ucontext_resp resp;
+	struct hns_roce_alloc_ucontext_resp resp = {};
 	struct hns_roce_device *hr_dev = to_hr_dev(ibdev);
 
 	context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index e2e27a6..4c60375 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -89,7 +89,7 @@  struct ibv_pd *hns_roce_u_alloc_pd(struct ibv_context *context)
 {
 	struct ibv_alloc_pd cmd;
 	struct hns_roce_pd *pd;
-	struct hns_roce_alloc_pd_resp resp;
+	struct hns_roce_alloc_pd_resp resp = {};
 
 	pd = (struct hns_roce_pd *)malloc(sizeof(*pd));
 	if (!pd)