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

Message ID 1738006389-17193-1-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Accepted
Delegated to: akhil goyal
Headers
Series [v3,1/3] lib/cryptodev: avoid implicit conversion to 64 bit number |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Jan. 27, 2025, 7:33 p.m. UTC
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@dpdk.org

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

Comments

Akhil Goyal Feb. 6, 2025, 12:08 p.m. UTC | #1
> 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@dpdk.org
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Acked-by: Akhil Goyal <gakhil@marvell.com>
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>

V2 of this patch was already applied to dpdk-next-crypto.

Now the other patches of the series are also applied.
Thanks.
  

Patch

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(