From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3D6A9A0A0A; Thu, 20 May 2021 10:43:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A616140143; Thu, 20 May 2021 10:43:55 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 7D38E40041; Thu, 20 May 2021 10:43:53 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D08451480; Thu, 20 May 2021 01:43:52 -0700 (PDT) Received: from net-x86-dell-8268.shanghai.arm.com (net-x86-dell-8268.shanghai.arm.com [10.169.210.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3801E3F719; Thu, 20 May 2021 01:43:48 -0700 (PDT) From: Feifei Wang To: John Griffin , Fiona Trahe , Deepak Kumar Jain , Herbert Guan , Jerin Jacob Cc: dev@dpdk.org, ferruh.yigit@intel.com, adamx.dybkowski@intel.com, nd@arm.com, Feifei Wang , stable@dpdk.org, Ruifeng Wang Date: Thu, 20 May 2021 16:43:33 +0800 Message-Id: <20210520084333.77775-1-feifei.wang2@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210514074113.2666225-1-feifei.wang2@arm.com> References: <20210514074113.2666225-1-feifei.wang2@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4] crypto/qat: fix uninitilized gcc compiler warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, gcc will report variable uninitilized warning: ../drivers/crypto/qat/qat_sym_session.c: In function ‘partial_hash_compute’: ../lib/eal/include/generic/rte_byteorder.h:241:24: warning: ‘’ may be used uninitialized in this function [-Wmaybe-uninitialized] 241 | #define rte_bswap32(x) __builtin_bswap32(x) ... This is because "digest" will be initialized by "rte_memcpy" function rather than "memcpy" if "RTE_ARCH_ARM64_MEMCPY" is set as true. Furthermore, 'rte_memcpy' will initialize 'digest' with two steps by invoking rte_mov_x functions. For example: partial_hash_sha1 -> rte_memcpy -> rte_memcpy_ge16_lt_128 -> step 1: rte_mov16(dst,src ) step 2: rte_mov16(dst - 16 + n, src - 16 + n) However, gcc compiler cannot identify this multi-step initialization, then it will report warning. To fix this, use "memset" to initialize "digest". Fixes: cd7fc8a84b48 ("eal/arm64: optimize memcpy") Cc: stable@dpdk.org Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang --- v2: add check and free for memory dynamic allocation (David Marchand) v3: fix compiler error v4: use 'memset' to initialize digest (Ferruh, Adam) drivers/crypto/qat/qat_sym_session.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 231b1640da..e22dd3600c 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -1196,6 +1196,9 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, uint64_t *hash_state_out_be64; int i; + /* Initialize to avoid gcc warning */ + memset(digest, 0, sizeof(digest)); + digest_size = qat_hash_get_digest_size(hash_alg); if (digest_size <= 0) return -EFAULT; -- 2.25.1