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 1C5AC45D7F; Thu, 28 Nov 2024 02:54:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 095BA4066C; Thu, 28 Nov 2024 02:54:40 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 24A5440151 for ; Thu, 28 Nov 2024 02:54:38 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 6B7362053048; Wed, 27 Nov 2024 17:54:37 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6B7362053048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1732758877; bh=YtCoscEOoHxu7TjbNwXPvbz/nF6P8AjBVZhy7BGeX9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q2dOWuX5Vz/ykf2CuUjgSWXflQDN/axUGY/T7Fy+uurdvfG+QWdEgjnxquvsOR2DV Dpwkc+vkPlburqyRFbtVrzjFS1DFXihQUQIaH3kXr+EPU0mte3Jzr5/XvtWO0qihop fbnxFtQg8YT0xgiEFbVg4GvzVloCXaFxX+KFrSBk= From: Andre Muezerie To: Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Cc: dev@dpdk.org, Andre Muezerie Subject: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number Date: Wed, 27 Nov 2024 17:53:57 -0800 Message-Id: <1732758837-6350-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> References: <1732758837-6350-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?) 1ULL should be used as the result of the bit shift gets multiplied by sizeof(uint32_t). Signed-off-by: Andre Muezerie --- 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 fa78787143..f076311b57 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) * (1ULL << 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 825da4382f..858884b4d4 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -119,16 +119,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.0.vfs.0.3