* [PATCH net-next] nfp: nsp: Simplify array allocation
@ 2022-01-26 16:30 Robin Murphy
2022-01-27 9:06 ` Simon Horman
2022-01-27 14:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Robin Murphy @ 2022-01-26 16:30 UTC (permalink / raw)
To: simon.horman, kuba, davem; +Cc: oss-drivers, netdev, linux-kernel
Prefer kcalloc() to kzalloc(array_size()) for allocating an array.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
index 10e7d8b21c46..730fea214b8a 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
@@ -513,7 +513,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,
dma_size = BIT_ULL(dma_order);
nseg = DIV_ROUND_UP(max_size, chunk_size);
- chunks = kzalloc(array_size(sizeof(*chunks), nseg), GFP_KERNEL);
+ chunks = kcalloc(nseg, sizeof(*chunks), GFP_KERNEL);
if (!chunks)
return -ENOMEM;
--
2.28.0.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] nfp: nsp: Simplify array allocation
2022-01-26 16:30 [PATCH net-next] nfp: nsp: Simplify array allocation Robin Murphy
@ 2022-01-27 9:06 ` Simon Horman
2022-01-27 12:42 ` Robin Murphy
2022-01-27 14:00 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Simon Horman @ 2022-01-27 9:06 UTC (permalink / raw)
To: Robin Murphy; +Cc: kuba, davem, oss-drivers, netdev, linux-kernel
On Wed, Jan 26, 2022 at 04:30:33PM +0000, Robin Murphy wrote:
> Prefer kcalloc() to kzalloc(array_size()) for allocating an array.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Hi Robin,
thanks for the cleanup.
One minor nit: I think "nfp: " would be a slightly more normal prefix
than "nfp: nsp: ".
That notwithstanding,
Acked-by: Simon Horman <simon.horman@corigine.com>
> ---
> drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
> index 10e7d8b21c46..730fea214b8a 100644
> --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
> +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
> @@ -513,7 +513,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,
> dma_size = BIT_ULL(dma_order);
> nseg = DIV_ROUND_UP(max_size, chunk_size);
>
> - chunks = kzalloc(array_size(sizeof(*chunks), nseg), GFP_KERNEL);
> + chunks = kcalloc(nseg, sizeof(*chunks), GFP_KERNEL);
> if (!chunks)
> return -ENOMEM;
>
> --
> 2.28.0.dirty
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] nfp: nsp: Simplify array allocation
2022-01-27 9:06 ` Simon Horman
@ 2022-01-27 12:42 ` Robin Murphy
0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2022-01-27 12:42 UTC (permalink / raw)
To: Simon Horman; +Cc: kuba, davem, oss-drivers, netdev, linux-kernel
On 2022-01-27 09:06, Simon Horman wrote:
> On Wed, Jan 26, 2022 at 04:30:33PM +0000, Robin Murphy wrote:
>> Prefer kcalloc() to kzalloc(array_size()) for allocating an array.
>>
>> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
>
> Hi Robin,
>
> thanks for the cleanup.
>
> One minor nit: I think "nfp: " would be a slightly more normal prefix
> than "nfp: nsp: ".
Ah, OK - from the git history it seemed about 50/50 one way or the
other, so I guessed at the one that looked more specific to this
particular file. I ran into this little anti-pattern in code I was
working on, and this was the only other instance that a quick grep
turned up so I figured I may as well fix it too.
> That notwithstanding,
>
> Acked-by: Simon Horman <simon.horman@corigine.com>
Thanks!
Robin.
>> ---
>> drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
>> index 10e7d8b21c46..730fea214b8a 100644
>> --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
>> +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
>> @@ -513,7 +513,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,
>> dma_size = BIT_ULL(dma_order);
>> nseg = DIV_ROUND_UP(max_size, chunk_size);
>>
>> - chunks = kzalloc(array_size(sizeof(*chunks), nseg), GFP_KERNEL);
>> + chunks = kcalloc(nseg, sizeof(*chunks), GFP_KERNEL);
>> if (!chunks)
>> return -ENOMEM;
>>
>> --
>> 2.28.0.dirty
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] nfp: nsp: Simplify array allocation
2022-01-26 16:30 [PATCH net-next] nfp: nsp: Simplify array allocation Robin Murphy
2022-01-27 9:06 ` Simon Horman
@ 2022-01-27 14:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-27 14:00 UTC (permalink / raw)
To: Robin Murphy; +Cc: simon.horman, kuba, davem, oss-drivers, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Wed, 26 Jan 2022 16:30:33 +0000 you wrote:
> Prefer kcalloc() to kzalloc(array_size()) for allocating an array.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Here is the summary with links:
- [net-next] nfp: nsp: Simplify array allocation
https://git.kernel.org/netdev/net-next/c/d9f393f468aa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-27 14:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-26 16:30 [PATCH net-next] nfp: nsp: Simplify array allocation Robin Murphy
2022-01-27 9:06 ` Simon Horman
2022-01-27 12:42 ` Robin Murphy
2022-01-27 14:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).