[v2,6/8] common/mlx5: fix calloc parameters

Message ID 20240124185406.3598985-6-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.1 20240124 (experimental)

[2]
Compiling C object .../common_mlx5_mlx5_common_mr.c.o
.../mlx5/mlx5_common_mr.c: In function ‘mlx5_mempool_get_chunks’:
.../common/mlx5/mlx5_common_mr.c:1384:29:
  warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
  argument and not in the later argument [-Wcalloc-transposed-args]
 1384 |         *out = calloc(sizeof(**out), n);
      |                             ^

Fixes: 7297d2cdecce ("common/mlx5: fix external memory pool registration")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
Cc: dkozlyuk@nvidia.com
---
 drivers/common/mlx5/mlx5_common_mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Morten Brørup Jan. 24, 2024, 7:01 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.1 20240124 (experimental)
> 
> [2]
> Compiling C object .../common_mlx5_mlx5_common_mr.c.o
> .../mlx5/mlx5_common_mr.c: In function ‘mlx5_mempool_get_chunks’:
> .../common/mlx5/mlx5_common_mr.c:1384:29:
>   warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
>   argument and not in the later argument [-Wcalloc-transposed-args]
>  1384 |         *out = calloc(sizeof(**out), n);
>       |                             ^
> 
> Fixes: 7297d2cdecce ("common/mlx5: fix external memory pool
> registration")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Dariusz Sosnowski Jan. 26, 2024, 10:12 a.m. UTC | #2
> -----Original Message-----
> From: Morten Brørup <mb@smartsharesystems.com>
> Sent: Wednesday, January 24, 2024 20:01
> To: Ferruh Yigit <ferruh.yigit@amd.com>; Dariusz Sosnowski
> <dsosnowski@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Ori
> Kam <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>; Matan
> Azrad <matan@nvidia.com>; Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Cc: dev@dpdk.org; stable@dpdk.org; dkozlyuk@nvidia.com
> Subject: RE: [PATCH v2 6/8] common/mlx5: fix calloc parameters 
> 
> > 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.1 20240124 (experimental)
> >
> > [2]
> > Compiling C object .../common_mlx5_mlx5_common_mr.c.o
> > .../mlx5/mlx5_common_mr.c: In function ‘mlx5_mempool_get_chunks’:
> > .../common/mlx5/mlx5_common_mr.c:1384:29:
> >   warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier
> >   argument and not in the later argument [-Wcalloc-transposed-args]
> >  1384 |         *out = calloc(sizeof(**out), n);
> >       |                             ^
> >
> > Fixes: 7297d2cdecce ("common/mlx5: fix external memory pool
> > registration")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
> > ---
> 
> Acked-by: Morten Brørup <mb@smartsharesystems.com>

Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
  

Patch

diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 40ff9153bd8e..85ec10d2ee36 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -1381,7 +1381,7 @@  mlx5_mempool_get_chunks(struct rte_mempool *mp, struct mlx5_range **out,
 
 	DRV_LOG(DEBUG, "Collecting chunks of regular mempool %s", mp->name);
 	n = mp->nb_mem_chunks;
-	*out = calloc(sizeof(**out), n);
+	*out = calloc(n, sizeof(**out));
 	if (*out == NULL)
 		return -1;
 	rte_mempool_mem_iter(mp, mlx5_range_from_mempool_chunk, *out);