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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: chenglang <chenglang@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx>
---
 providers/hns/hns_roce_u.c       | 2 +-
 providers/hns/hns_roce_u_verbs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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)
-- 
2.8.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux