[2/2] net/nfp: fix calloc parameters

Message ID 20231102130847.3367102-2-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
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

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 .../net_nfp_nfpcore_nfp_mutex.c.o
.../net/nfp/nfpcore/nfp_mutex.c: In function ‘nfp_cpp_mutex_alloc’:
../drivers/net/nfp/nfpcore/nfp_mutex.c:171:15:
  warning: allocation of insufficient size ‘1’ for type
           ‘struct nfp_cpp_mutex’ with size ‘48’ [-Walloc-size]
  171 |         mutex = calloc(sizeof(*mutex), 1);
      |               ^

Fixes: c7e9729da6b5 ("net/nfp: support CPP")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
Cc: alejandro.lucero@netronome.com
---
 drivers/net/nfp/nfpcore/nfp_mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Chaoyong He Nov. 3, 2023, 1:26 a.m. UTC | #1
> 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 .../net_nfp_nfpcore_nfp_mutex.c.o
> .../net/nfp/nfpcore/nfp_mutex.c: In function ‘nfp_cpp_mutex_alloc’:
> ../drivers/net/nfp/nfpcore/nfp_mutex.c:171:15:
>   warning: allocation of insufficient size ‘1’ for type
>            ‘struct nfp_cpp_mutex’ with size ‘48’ [-Walloc-size]
>   171 |         mutex = calloc(sizeof(*mutex), 1);
>       |               ^
> 
> Fixes: c7e9729da6b5 ("net/nfp: support CPP")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---
> Cc: alejandro.lucero@netronome.com
> ---
>  drivers/net/nfp/nfpcore/nfp_mutex.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c
> b/drivers/net/nfp/nfpcore/nfp_mutex.c
> index 3c10c7a090c0..edb78dfdc917 100644
> --- a/drivers/net/nfp/nfpcore/nfp_mutex.c
> +++ b/drivers/net/nfp/nfpcore/nfp_mutex.c
> @@ -168,7 +168,7 @@ nfp_cpp_mutex_alloc(struct nfp_cpp *cpp,
>  	if (tmp != key)
>  		return NULL;
> 
> -	mutex = calloc(sizeof(*mutex), 1);
> +	mutex = calloc(1, sizeof(*mutex));
>  	if (mutex == NULL)
>  		return NULL;
> 
> --
> 2.34.1

Thanks for fix it.

Acked-by: Chaoyong He <chaoyong.he@corigine.com>
  

Patch

diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c
index 3c10c7a090c0..edb78dfdc917 100644
--- a/drivers/net/nfp/nfpcore/nfp_mutex.c
+++ b/drivers/net/nfp/nfpcore/nfp_mutex.c
@@ -168,7 +168,7 @@  nfp_cpp_mutex_alloc(struct nfp_cpp *cpp,
 	if (tmp != key)
 		return NULL;
 
-	mutex = calloc(sizeof(*mutex), 1);
+	mutex = calloc(1, sizeof(*mutex));
 	if (mutex == NULL)
 		return NULL;