[v2,3/8] rawdev: fix calloc parameters

Message ID 20240124185406.3598985-3-ferruh.yigit@amd.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/8] pipeline: fix calloc parameters |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Jan. 24, 2024, 6:54 p.m. UTC
  gcc [1] generates warning [2] about calloc usage, because calloc
parameter order is wrong, fixing it by replacing parameters.

[1]
gcc (GCC) 14.0.0 20240108 (experimental)

[2]
Compiling C object .../lib/librte_rawdev.a.p/rawdev_rte_rawdev.c.o
../lib/rawdev/rte_rawdev.c: In function ‘handle_dev_dump’:
../lib/rawdev/rte_rawdev.c:659:29:
  error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
  argument and not in the later argument
  [-Werror=calloc-transposed-args]
  659 |     buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
      |                         ^~~~

Fixes: e915d404eb72 ("rawdev: support telemetry dump rawdev")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
Cc: fengchengwen@huawei.com
---
 lib/rawdev/rte_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Morten Brørup Jan. 24, 2024, 6:59 p.m. UTC | #1
> From: Ferruh Yigit [mailto:ferruh.yigit@amd.com]
> Sent: Wednesday, 24 January 2024 19.54
> 
> gcc [1] generates warning [2] about calloc usage, because calloc
> parameter order is wrong, fixing it by replacing parameters.
> 
> [1]
> gcc (GCC) 14.0.0 20240108 (experimental)
> 
> [2]
> Compiling C object .../lib/librte_rawdev.a.p/rawdev_rte_rawdev.c.o
> ../lib/rawdev/rte_rawdev.c: In function ‘handle_dev_dump’:
> ../lib/rawdev/rte_rawdev.c:659:29:
>   error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
>   argument and not in the later argument
>   [-Werror=calloc-transposed-args]
>   659 |     buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
>       |                         ^~~~
> 
> Fixes: e915d404eb72 ("rawdev: support telemetry dump rawdev")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
fengchengwen Jan. 25, 2024, 2:34 a.m. UTC | #2
Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>

Thanks

On 2024/1/25 2:54, Ferruh Yigit wrote:
> gcc [1] generates warning [2] about calloc usage, because calloc
> parameter order is wrong, fixing it by replacing parameters.
> 
> [1]
> gcc (GCC) 14.0.0 20240108 (experimental)
> 
> [2]
> Compiling C object .../lib/librte_rawdev.a.p/rawdev_rte_rawdev.c.o
> ../lib/rawdev/rte_rawdev.c: In function ‘handle_dev_dump’:
> ../lib/rawdev/rte_rawdev.c:659:29:
>   error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
>   argument and not in the later argument
>   [-Werror=calloc-transposed-args]
>   659 |     buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
>       |                         ^~~~
> 
> Fixes: e915d404eb72 ("rawdev: support telemetry dump rawdev")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---
> Cc: fengchengwen@huawei.com
> ---
>  lib/rawdev/rte_rawdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c
> index 474bdc95407f..4f8897b63947 100644
> --- a/lib/rawdev/rte_rawdev.c
> +++ b/lib/rawdev/rte_rawdev.c
> @@ -656,7 +656,7 @@ handle_dev_dump(const char *cmd __rte_unused,
>  	if (!rte_rawdev_pmd_is_valid_dev(dev_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;
>  
>
  
Hemant Agrawal Jan. 25, 2024, 3:39 a.m. UTC | #3
> gcc [1] generates warning [2] about calloc usage, because calloc parameter
> order is wrong, fixing it by replacing parameters.
> 
> [1]
> gcc (GCC) 14.0.0 20240108 (experimental)
> 
> [2]
> Compiling C object .../lib/librte_rawdev.a.p/rawdev_rte_rawdev.c.o
> ../lib/rawdev/rte_rawdev.c: In function ‘handle_dev_dump’:
> ../lib/rawdev/rte_rawdev.c:659:29:
>   error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
>   argument and not in the later argument
>   [-Werror=calloc-transposed-args]
>   659 |     buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
>       |                         ^~~~
> 
> Fixes: e915d404eb72 ("rawdev: support telemetry dump rawdev")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>

Reviewed-by:  Hemant Agrawal <hemant.agrawal@nxp.com>
  

Patch

diff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c
index 474bdc95407f..4f8897b63947 100644
--- a/lib/rawdev/rte_rawdev.c
+++ b/lib/rawdev/rte_rawdev.c
@@ -656,7 +656,7 @@  handle_dev_dump(const char *cmd __rte_unused,
 	if (!rte_rawdev_pmd_is_valid_dev(dev_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;