[v2,2/8] net/nfp: fix calloc parameters

Message ID 20240124185406.3598985-2-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:53 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>
Acked-by: Chaoyong He <chaoyong.he@corigine.com>
---
Cc: alejandro.lucero@netronome.com
---
 drivers/net/nfp/nfpcore/nfp_mutex.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.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>
> Acked-by: Chaoyong He <chaoyong.he@corigine.com>
> ---

Acked-by: Morten Brørup <mb@smartsharesystems.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;