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 7064246135; Mon, 27 Jan 2025 17:04:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE7A740698; Mon, 27 Jan 2025 17:04:03 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 40DFA4027D for ; Mon, 27 Jan 2025 17:04:01 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 694492066C19; Mon, 27 Jan 2025 08:04:00 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 694492066C19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1737993840; bh=RboqnBayPAJJlG5lVfW7eZMtMebOjcrQUuyv47+AsT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfO+B1oh2hRARsNvpZYe3MSqBiv+Zt031rwv1U7qFb312ZKSm+hwEMwll+Zwm4PZL lGLfycP+BIimI2KSwpb7/lfP9fy7gp750n2NJslMkn1iHNLXIwvWOz+yTi7wTe986+ mBV9JvR57+PWtPKdBtq18GIaPgJn7qExu2Ff5eTY= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: dev@dpdk.org, fanzhang.oss@gmail.com, gakhil@marvell.com, mb@smartsharesystems.com Subject: [PATCH v2 2/2] lib/hash: avoid implicit conversion to 64 bit number Date: Mon, 27 Jan 2025 08:03:53 -0800 Message-Id: <1737993833-22957-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1737993833-22957-1-git-send-email-andremue@linux.microsoft.com> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1737993833-22957-1-git-send-email-andremue@linux.microsoft.com> 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 --- 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