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 272C24613B; Mon, 27 Jan 2025 20:33:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C62B40B9A; Mon, 27 Jan 2025 20:33:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3F08240A72 for ; Mon, 27 Jan 2025 20:33:18 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 5FBAC2037169; Mon, 27 Jan 2025 11:33:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FBAC2037169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738006397; bh=I4QUXro6OvpR//vJkNvDVRpdATmGstYR3LVYmdmgiPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OsiTk0/heiiBEKiapjeXYGOaPrj9/myOEyzhmyCPrV2FfOECB30EGf3ueIA1izWpM GIWULpqftfB66mDMCnIKVhrLE8fQkFkHnn44bEQMHyiaAb/4GyPqMjkUm0ihYr0dCU dR7mIQAdayiAeWgIRAJNokYgJXep3gM1w6YsNOe0= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: dev@dpdk.org, fanzhang.oss@gmail.com, gakhil@marvell.com, mb@smartsharesystems.com Subject: [PATCH v3 2/3] lib/hash: avoid implicit conversion to 64 bit number Date: Mon, 27 Jan 2025 11:33:08 -0800 Message-Id: <1738006389-17193-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 MSVC issues the warnings below: 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) The code would be better off by using 64 bit numbers to begin with. That eliminates the need for a conversion to 64 bits later. 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) Instead of multiplying sizeof(uint32_t) by the result of shifting "1", sizeof(uint32_t) can be shifted directly. Signed-off-by: Andre Muezerie Acked-by: Vladimir Medvedkin Acked-by: Bruce Richardson Reviewed-by: Morten Brørup --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 336c228e64..429b895d6c 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, offset; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + - sizeof(uint32_t) * (1 << ctx->reta_sz_log), + (sizeof(uint32_t) << ctx->reta_sz_log), RTE_CACHE_LINE_SIZE); if (ent == NULL) return -ENOMEM; diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c index 1c62974e71..a28f2495a5 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -118,16 +118,16 @@ static uint32_t gf2_mul(uint32_t a, uint32_t b, uint32_t r, int degree) { uint64_t product = 0; - uint64_t r_poly = r|(1ULL << degree); + uint64_t r_poly = r | RTE_BIT64(degree); for (; b; b &= (b - 1)) product ^= (uint64_t)a << (rte_bsf32(b)); for (int i = degree * 2 - 1; i >= degree; i--) - if (product & (1 << i)) + if (product & RTE_BIT64(i)) product ^= r_poly << (i - degree); - return product; + return (uint32_t)product; } static uint32_t -- 2.47.2.vfs.0.1