From patchwork Tue Feb 19 09:06:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10819519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44392184E for ; Tue, 19 Feb 2019 09:06:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EBDA2B3EF for ; Tue, 19 Feb 2019 09:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2304A2B506; Tue, 19 Feb 2019 09:06:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6FED2B3EF for ; Tue, 19 Feb 2019 09:06:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727361AbfBSJG2 (ORCPT ); Tue, 19 Feb 2019 04:06:28 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:4222 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726695AbfBSJG1 (ORCPT ); Tue, 19 Feb 2019 04:06:27 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 855785E2E8A019328F72; Tue, 19 Feb 2019 17:06:24 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Tue, 19 Feb 2019 17:06:16 +0800 From: Lijun Ou To: , CC: , , Subject: [PATCH V2 rdma-core 2/5] libhns: Fix errors detected by Cppcheck tool Date: Tue, 19 Feb 2019 17:06:38 +0800 Message-ID: <1550567201-226345-3-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1550567201-226345-1-git-send-email-oulijun@huawei.com> References: <1550567201-226345-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: chenglang 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 Signed-off-by: Lijun Ou --- 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)