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 BA17F45E3A; Thu, 5 Dec 2024 16:34:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50B7040648; Thu, 5 Dec 2024 16:34:25 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D9C92402E3 for ; Thu, 5 Dec 2024 16:34:23 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 362FC20BCAEA; Thu, 5 Dec 2024 07:34:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 362FC20BCAEA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1733412863; bh=ZPPml++orAlM8zj/7cjeVZW/voYCJjqGXYeE9lNwO7E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nHoPG5UKpXja6qcyYJNzC/S65nYJZKWv5S0z1VKWqh9IulqDzmnYdGTFDv3lr7UXo v/lViSUtZYTC5Zs59t4XlsVl2b8lw8+Muq+h9BoFQqewdflN/szRe85Ajx9d8zFCKJ DgrMh125hYsd9MztpfxTBWoAxinpq0gXpi4OO440= Date: Thu, 5 Dec 2024 07:34:23 -0800 From: Andre Muezerie To: Stephen Hemminger Cc: Vladimir Medvedkin , dev@dpdk.org Subject: Re: [PATCH] lib/fib: remove warning about implicit 64-bit conversion Message-ID: <20241205153423.GA25118@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1733281010-23780-1-git-send-email-andremue@linux.microsoft.com> <20241204145940.25cd99ea@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241204145940.25cd99ea@hermes.local> 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, Dec 04, 2024 at 02:59:40PM -0800, Stephen Hemminger wrote: > On Tue, 3 Dec 2024 18:56:50 -0800 > Andre Muezerie wrote: > > > MSVC issues the warning below: > > > > ../lib/fib/trie.c(341): warning C4334: '<<': > > result of 32-bit shift implicitly converted to 64 bits > > (was 64-bit shift intended?) > > > > The fix is to cast the result explicitly to ptrdiff_t since it is used > > in pointer arithmetic. > > > > Signed-off-by: Andre Muezerie > > --- > > lib/fib/trie.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/fib/trie.c b/lib/fib/trie.c > > index 4893f6c636..997b7cc338 100644 > > --- a/lib/fib/trie.c > > +++ b/lib/fib/trie.c > > @@ -338,7 +338,7 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop, > > if (ret < 0) > > return ret; > > if (edge == LEDGE) { > > - write_to_dp((uint8_t *)p + (1 << dp->nh_sz), > > + write_to_dp((uint8_t *)p + (ptrdiff_t)(1 << dp->nh_sz), > > next_hop << 1, dp->nh_sz, UINT8_MAX - *ip_part); > > You would be better to use a 64 bit shift or RTE_BIT64 for this. > > write_to_dp((uint8_t *)p + ((uintptr_t)1 << dp->nh_sz), Thanks for the suggestion. I'll update the patch.