[PATCH v3 1/3] lib/cryptodev: avoid implicit conversion to 64 bit number

Andre Muezerie andremue at linux.microsoft.com
Mon Jan 27 20:33:07 CET 2025


MSVC issues the warning below:

../lib/cryptodev/rte_cryptodev.c(623): 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.

This patch actually fixes a bug present in previous DPDK versions
because the last of the hash enums RTE_CRYPTO_AUTH_SM3_HMAC in
rte_crypto_auth_algorithm has value 32.

Fixes: 6f8ef8b68edb ("cryptodev: add hash algorithms in asymmetric capability")
Cc: stable at dpdk.org

Signed-off-by: Andre Muezerie <andremue at linux.microsoft.com>
Acked-by: Akhil Goyal <gakhil at marvell.com>
Reviewed-by: Morten Brørup <mb at smartsharesystems.com>
---
 lib/cryptodev/rte_cryptodev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 85a4b46ac9..a49b0662f3 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -620,7 +620,7 @@ rte_cryptodev_asym_xform_capability_check_hash(
 {
 	bool ret = false;
 
-	if (capability->hash_algos & (1 << hash))
+	if (capability->hash_algos & RTE_BIT64(hash))
 		ret = true;
 
 	rte_cryptodev_trace_asym_xform_capability_check_hash(
-- 
2.47.2.vfs.0.1



More information about the dev mailing list