[1/2] pipeline: fix calloc parameters

Message ID 20231102130847.3367102-1-ferruh.yigit@amd.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series [1/2] pipeline: fix calloc parameters |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Nov. 2, 2023, 1:08 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 20231102 (experimental)

[2]
 Compiling C object .../pipeline_rte_swx_pipeline_spec.c.o
.../rte_swx_pipeline_spec.c: In function ‘pipeline_spec_parse’:
../lib/pipeline/rte_swx_pipeline_spec.c:2893:11:
  warning: allocation of insufficient size ‘1’ for type
           ‘struct pipeline_spec’ with size ‘144’ [-Walloc-size]
 2893 |         s = calloc(sizeof(struct pipeline_spec), 1);
      |           ^

.../rte_swx_pipeline_spec.c: In function ‘pipeline_iospec_parse’:
../lib/pipeline/rte_swx_pipeline_spec.c:4244:11:
  warning: allocation of insufficient size ‘1’ for type
           ‘struct pipeline_iospec’ with size ‘64’ [-Walloc-size]
 4244 |         s = calloc(sizeof(struct pipeline_iospec), 1);
      |           ^

Fixes: 30c4abb90942 ("pipeline: rework specification file-based pipeline build")
Fixes: 54cae37ef4ef ("pipeline: support I/O specification")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
Cc: cristian.dumitrescu@intel.com
---
 lib/pipeline/rte_swx_pipeline_spec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Cristian Dumitrescu Nov. 6, 2023, 2:26 p.m. UTC | #1
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> Sent: Thursday, November 2, 2023 1:09 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; R, Kamalakannan
> <kamalakannan.r@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH 1/2] pipeline: fix calloc parameters
> 
> 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 20231102 (experimental)
> 
> [2]
>  Compiling C object .../pipeline_rte_swx_pipeline_spec.c.o
> .../rte_swx_pipeline_spec.c: In function ‘pipeline_spec_parse’:
> ../lib/pipeline/rte_swx_pipeline_spec.c:2893:11:
>   warning: allocation of insufficient size ‘1’ for type
>            ‘struct pipeline_spec’ with size ‘144’ [-Walloc-size]
>  2893 |         s = calloc(sizeof(struct pipeline_spec), 1);
>       |           ^
> 
> .../rte_swx_pipeline_spec.c: In function ‘pipeline_iospec_parse’:
> ../lib/pipeline/rte_swx_pipeline_spec.c:4244:11:
>   warning: allocation of insufficient size ‘1’ for type
>            ‘struct pipeline_iospec’ with size ‘64’ [-Walloc-size]
>  4244 |         s = calloc(sizeof(struct pipeline_iospec), 1);
>       |           ^
> 
> Fixes: 30c4abb90942 ("pipeline: rework specification file-based pipeline
> build")
> Fixes: 54cae37ef4ef ("pipeline: support I/O specification")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  

Patch

diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c
index 2bba0d0524d0..17419e7b854b 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.c
+++ b/lib/pipeline/rte_swx_pipeline_spec.c
@@ -2890,7 +2890,7 @@  pipeline_spec_parse(FILE *spec,
 	}
 
 	/* Memory allocation. */
-	s = calloc(sizeof(struct pipeline_spec), 1);
+	s = calloc(1, sizeof(struct pipeline_spec));
 	if (!s) {
 		if (err_line)
 			*err_line = n_lines;
@@ -4241,7 +4241,7 @@  pipeline_iospec_parse(FILE *spec,
 	}
 
 	/* Memory allocation. */
-	s = calloc(sizeof(struct pipeline_iospec), 1);
+	s = calloc(1, sizeof(struct pipeline_iospec));
 	if (!s) {
 		if (err_line)
 			*err_line = n_lines;