[v2,1/2] test/efd: fix size of constant

Message ID 20220224155759.819460-1-pablo.de.lara.guarch@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/2] test/efd: fix size of constant |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

De Lara Guarch, Pablo Feb. 24, 2022, 3:57 p.m. UTC
  Constant value 1 has a size of 32 bits, and shifting it more than 32 bits
to the left overflows. 1ULL is needed to be able to get a 64-bit value.

Coverity ID: 375846
Fixes: 8751a7e9832b ("efd: allow more CPU sockets in table creation")
Cc: pablo.de.lara.guarch@intel.com
Cc: stable@dpdk.org

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_efd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Wang, Yipeng1 Feb. 24, 2022, 5:15 p.m. UTC | #1
> -----Original Message-----
> From: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Sent: Thursday, February 24, 2022 7:58 AM
> To: Wang, Yipeng1 <yipeng1.wang@intel.com>; Marohn, Byron
> <byron.marohn@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v2 1/2] test/efd: fix size of constant
> 
> Constant value 1 has a size of 32 bits, and shifting it more than 32 bits to the
> left overflows. 1ULL is needed to be able to get a 64-bit value.
> 
> Coverity ID: 375846
> Fixes: 8751a7e9832b ("efd: allow more CPU sockets in table creation")
> Cc: pablo.de.lara.guarch@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  app/test/test_efd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test/test_efd.c b/app/test/test_efd.c index
> 7bea674086..fa29e8f97a 100644
> --- a/app/test/test_efd.c
> +++ b/app/test/test_efd.c
> @@ -107,7 +107,7 @@ static inline uint64_t
> efd_get_all_sockets_bitmask(void)
>  	unsigned int next_lcore = rte_get_main_lcore();
>  	const int val_true = 1, val_false = 0;
>  	for (i = 0; i < rte_lcore_count(); i++) {
> -		all_cpu_sockets_bitmask |= 1 <<
> rte_lcore_to_socket_id(next_lcore);
> +		all_cpu_sockets_bitmask |= 1ULL <<
> +rte_lcore_to_socket_id(next_lcore);
>  		next_lcore = rte_get_next_lcore(next_lcore, val_false,
> val_true);
>  	}
> 
> --
> 2.25.1
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
  

Patch

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index 7bea674086..fa29e8f97a 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -107,7 +107,7 @@  static inline uint64_t efd_get_all_sockets_bitmask(void)
 	unsigned int next_lcore = rte_get_main_lcore();
 	const int val_true = 1, val_false = 0;
 	for (i = 0; i < rte_lcore_count(); i++) {
-		all_cpu_sockets_bitmask |= 1 << rte_lcore_to_socket_id(next_lcore);
+		all_cpu_sockets_bitmask |= 1ULL << rte_lcore_to_socket_id(next_lcore);
 		next_lcore = rte_get_next_lcore(next_lcore, val_false, val_true);
 	}