netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: openvswitch: Use struct_size()
@ 2023-05-06 16:04 Christophe JAILLET
  2023-05-06 18:12 ` Simon Horman
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christophe JAILLET @ 2023-05-06 16:04 UTC (permalink / raw)
  To: Pravin B Shelar, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev, dev

Use struct_size() instead of hand writing it.
This is less verbose and more informative.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
It will also help scripts when __counted_by macro will be added.
See [1].

[1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/
---
 net/openvswitch/meter.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index f2698d2316df..c4ebf810e4b1 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -69,9 +69,7 @@ static struct dp_meter_instance *dp_meter_instance_alloc(const u32 size)
 {
 	struct dp_meter_instance *ti;
 
-	ti = kvzalloc(sizeof(*ti) +
-		      sizeof(struct dp_meter *) * size,
-		      GFP_KERNEL);
+	ti = kvzalloc(struct_size(ti, dp_meters, size), GFP_KERNEL);
 	if (!ti)
 		return NULL;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: openvswitch: Use struct_size()
  2023-05-06 16:04 [PATCH net-next] net: openvswitch: Use struct_size() Christophe JAILLET
@ 2023-05-06 18:12 ` Simon Horman
  2023-05-13  7:25 ` [RESEND PATCH " Christophe JAILLET
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-05-06 18:12 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Pravin B Shelar, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-kernel, kernel-janitors, netdev, dev

On Sat, May 06, 2023 at 06:04:16PM +0200, Christophe JAILLET wrote:
> Use struct_size() instead of hand writing it.
> This is less verbose and more informative.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> It will also help scripts when __counted_by macro will be added.
> See [1].
> 
> [1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/

This looks fine to me, but:

## Form letter - net-next-closed (text borrowed from others)

The merge window for v6.3 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We are currently accepting bug fixes only.

Please repost when net-next reopens after May 8th.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RESEND PATCH net-next] net: openvswitch: Use struct_size()
  2023-05-06 16:04 [PATCH net-next] net: openvswitch: Use struct_size() Christophe JAILLET
  2023-05-06 18:12 ` Simon Horman
@ 2023-05-13  7:25 ` Christophe JAILLET
  2023-05-15  7:12 ` Eelco Chaudron
  2023-05-18  4:40 ` [PATCH " patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2023-05-13  7:25 UTC (permalink / raw)
  To: Pravin B Shelar, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev, dev

Use struct_size() instead of hand writing it.
This is less verbose and more informative.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
It will also help scripts when __counted_by macro will be added.
See [1].

[1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/


Resending now that net-next is re-opened.
---
 net/openvswitch/meter.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index f2698d2316df..c4ebf810e4b1 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -69,9 +69,7 @@ static struct dp_meter_instance *dp_meter_instance_alloc(const u32 size)
 {
 	struct dp_meter_instance *ti;
 
-	ti = kvzalloc(sizeof(*ti) +
-		      sizeof(struct dp_meter *) * size,
-		      GFP_KERNEL);
+	ti = kvzalloc(struct_size(ti, dp_meters, size), GFP_KERNEL);
 	if (!ti)
 		return NULL;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RESEND PATCH net-next] net: openvswitch: Use struct_size()
  2023-05-06 16:04 [PATCH net-next] net: openvswitch: Use struct_size() Christophe JAILLET
  2023-05-06 18:12 ` Simon Horman
  2023-05-13  7:25 ` [RESEND PATCH " Christophe JAILLET
@ 2023-05-15  7:12 ` Eelco Chaudron
  2023-05-18  4:40 ` [PATCH " patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Eelco Chaudron @ 2023-05-15  7:12 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Pravin B Shelar, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-kernel, kernel-janitors, netdev, dev



On 13 May 2023, at 9:25, Christophe JAILLET wrote:

> Use struct_size() instead of hand writing it.
> This is less verbose and more informative.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Change looks good to me.

Acked-by: Eelco Chaudron <echaudro@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: openvswitch: Use struct_size()
  2023-05-06 16:04 [PATCH net-next] net: openvswitch: Use struct_size() Christophe JAILLET
                   ` (2 preceding siblings ...)
  2023-05-15  7:12 ` Eelco Chaudron
@ 2023-05-18  4:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-18  4:40 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: pshelar, davem, edumazet, kuba, pabeni, linux-kernel,
	kernel-janitors, netdev, dev

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat,  6 May 2023 18:04:16 +0200 you wrote:
> Use struct_size() instead of hand writing it.
> This is less verbose and more informative.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> It will also help scripts when __counted_by macro will be added.
> See [1].
> 
> [...]

Here is the summary with links:
  - [net-next] net: openvswitch: Use struct_size()
    https://git.kernel.org/netdev/net-next/c/b50a8b0d57ab

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] 5+ messages in thread

end of thread, other threads:[~2023-05-18  4:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-06 16:04 [PATCH net-next] net: openvswitch: Use struct_size() Christophe JAILLET
2023-05-06 18:12 ` Simon Horman
2023-05-13  7:25 ` [RESEND PATCH " Christophe JAILLET
2023-05-15  7:12 ` Eelco Chaudron
2023-05-18  4:40 ` [PATCH " 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).