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 2DDAC460EE; Wed, 22 Jan 2025 22:36:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA4A6402E1; Wed, 22 Jan 2025 22:36:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5909140294 for ; Wed, 22 Jan 2025 22:36:44 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 2545420460B2; Wed, 22 Jan 2025 13:36:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2545420460B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1737581803; bh=on6B8evOzd7rH4cZNUeVkk4sVfeVJPD6M3g6mS2qcG4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JqEo7SVHw6SxDQaaYq/7AFihyQvuFEzL7ADgMNrZ4JbWf8HmBHAvSZW6lKBmi1G1c FBPbAjGCWN8m2pgPgSXS5XNZV8Z4aDfHNP53YufRkqmGIR9WsX/8aP/APvE7UEnXnI gmRJ2zOaaWyPM8/wSrpVjhn+DSHCh+wGRzMuhLsE= Date: Wed, 22 Jan 2025 13:36:43 -0800 From: Andre Muezerie To: Bruce Richardson Cc: Yipeng Wang , Sameh Gobriel , Vladimir Medvedkin , dev@dpdk.org Subject: Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number Message-ID: <20250122213643.GA26516@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1732758837-6350-2-git-send-email-andremue@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Wed, Jan 22, 2025 at 04:12:49PM +0000, Bruce Richardson wrote: > On Wed, Nov 27, 2024 at 05:53:57PM -0800, Andre Muezerie wrote: > > 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 > > --- > > 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 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); > > Is there a reason not to use RTE_BIT64 here too? Here we are calculating the size to be passed to the second argument of rte_zmalloc, which is of type size_t. size_t is implementation dependent, typically 4 bytes on 32-bit systems and 8 bytes on 64-bit systems, so using 1ULL seems more appropriate.