Skip to content

Commit

Permalink
pipeline: fix calloc parameters
Browse files Browse the repository at this point in the history
[ upstream commit 0594ae0c42773d62aff870df25e73394f7f0a5a5 ]

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: 30c4abb ("pipeline: rework specification file-based pipeline build")
Fixes: 54cae37 ("pipeline: support I/O specification")

Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
  • Loading branch information
ferruhy authored and bluca committed Mar 7, 2024
1 parent e0cc2ba commit eb18df7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pipeline/rte_swx_pipeline_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,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;
Expand Down Expand Up @@ -4145,7 +4145,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;
Expand Down

0 comments on commit eb18df7

Please sign in to comment.