[PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Bruce Richardson
bruce.richardson at intel.com
Wed Jan 22 17:12:49 CET 2025
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 at linux.microsoft.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson at 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?
More information about the dev
mailing list