Skip to content

Commit

Permalink
net/nfp: fix calloc parameters
Browse files Browse the repository at this point in the history
[ upstream commit 0352f47a3bf923574afe17e822af58bedc7ead49 ]

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: c7e9729 ("net/nfp: support CPP")

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>
  • Loading branch information
ferruhy authored and bluca committed Mar 7, 2024
1 parent 5cad6d4 commit 0b4a4ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/nfp/nfpcore/nfp_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ nfp_cpp_mutex_alloc(struct nfp_cpp *cpp, int target,
if (tmp != key)
return NFP_ERRPTR(EEXIST);

mutex = calloc(sizeof(*mutex), 1);
mutex = calloc(1, sizeof(*mutex));
if (!mutex)
return NFP_ERRPTR(ENOMEM);

Expand Down

0 comments on commit 0b4a4ac

Please sign in to comment.