From: Andre Muezerie <andremue@linux.microsoft.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: Yipeng Wang <yipeng1.wang@intel.com>,
Sameh Gobriel <sameh.gobriel@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
dev@dpdk.org
Subject: Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Date: Wed, 22 Jan 2025 13:36:43 -0800 [thread overview]
Message-ID: <20250122213643.GA26516@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <Z5EZAXq5o9PXx0Be@bricha3-mobl1.ger.corp.intel.com>
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 <andremue@linux.microsoft.com>
> > ---
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
> > 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.
next prev parent reply other threads:[~2025-01-22 21:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 1:53 [PATCH 1/2] lib/cryptodev: " Andre Muezerie
2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie
2025-01-22 16:12 ` Bruce Richardson
2025-01-22 21:36 ` Andre Muezerie [this message]
2025-01-22 16:15 ` Medvedkin, Vladimir
2025-01-08 10:28 ` [EXTERNAL] [PATCH 1/2] lib/cryptodev: " Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250122213643.GA26516@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
--to=andremue@linux.microsoft.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=sameh.gobriel@intel.com \
--cc=vladimir.medvedkin@intel.com \
--cc=yipeng1.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).