[v2,01/13] ethdev: fix incorrect argument of calloc

Message ID 20230607074209.4798-2-haijie1@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series support telemetry query ethdev info |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jie Hai June 7, 2023, 7:41 a.m. UTC
  The 'calloc' uses number as first argument, sizeof is generally wrong.
This patch fixes it.

Fixes: 8af559f94cef ("ethdev: support telemetry private dump")
Cc: stable@dpdk.org

Signed-off-by: Jie Hai <haijie1@huawei.com>
---
 lib/ethdev/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit June 7, 2023, 11:35 a.m. UTC | #1
On 6/7/2023 8:41 AM, Jie Hai wrote:
> The 'calloc' uses number as first argument, sizeof is generally wrong.
> This patch fixes it.
> 
> Fixes: 8af559f94cef ("ethdev: support telemetry private dump")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> ---
>  lib/ethdev/rte_ethdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index d46e74504e64..503d500429c0 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -6548,7 +6548,7 @@ eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
>  	if (!rte_eth_dev_is_valid_port(port_id))
>  		return -EINVAL;
>  
> -	buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
> +	buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
>  	if (buf == NULL)
>  		return -ENOMEM;
>  

Functionality should be same, but there is no harm to fix, hence:

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  

Patch

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d46e74504e64..503d500429c0 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6548,7 +6548,7 @@  eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -EINVAL;
 
-	buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
+	buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
 	if (buf == NULL)
 		return -ENOMEM;