netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC net-next 0/2] introduce DECLARE_FLEX() macro
@ 2023-08-01 11:19 Przemek Kitszel
  2023-08-01 11:19 ` [RFC net-next 1/2] overflow: add DECLARE_FLEX() for on-stack allocs Przemek Kitszel
  2023-08-01 11:19 ` [RFC net-next 2/2] ice: make use of DECLARE_FLEX() in ice_switch.c Przemek Kitszel
  0 siblings, 2 replies; 18+ messages in thread
From: Przemek Kitszel @ 2023-08-01 11:19 UTC (permalink / raw)
  To: Kees Cook
  Cc: Jacob Keller, intel-wired-lan, netdev, Alexander Lobakin,
	Przemek Kitszel

Add DECLARE_FLEX() macro that lets us declare structures with flexible
array members on stack (patch 1).

Show how it could be used by ice example (note that post-RFC version will
cover whole driver, here is just one file) (patch 2).

Two open questions:
Any better macro name?
Especially given it's valid only for on stack allocations,
(ie. could not be placed into struct definitions).

More sugar?
It's tempting to introduce yet another macro that would avoid
repetition of flex array field name and count, eg to apply:
-struct_size(sw_buf, elem, 1)
+flex_sizeof(sw_buf)

With simple definition:
+#define flex_sizeof(var) \
+	sizeof(var##_buf)

Yet I'm unsure if usage it's not too magical then?

Przemek Kitszel (2):
  overflow: add DECLARE_FLEX() for on-stack allocs
  ice: make use of DECLARE_FLEX() in ice_switch.c

 drivers/net/ethernet/intel/ice/ice_switch.c | 53 +++++----------------
 include/linux/overflow.h                    | 14 ++++++
 2 files changed, 26 insertions(+), 41 deletions(-)


base-commit: 9d1505d88ad0f6970015a06a475b9d67b21f20fa
-- 
2.38.1


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

end of thread, other threads:[~2023-08-07 14:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01 11:19 [RFC net-next 0/2] introduce DECLARE_FLEX() macro Przemek Kitszel
2023-08-01 11:19 ` [RFC net-next 1/2] overflow: add DECLARE_FLEX() for on-stack allocs Przemek Kitszel
2023-08-01 13:54   ` Alexander Lobakin
2023-08-01 14:18     ` Przemek Kitszel
2023-08-01 17:15       ` Alexander Lobakin
2023-08-01 22:31   ` Kees Cook
2023-08-04 10:59     ` Przemek Kitszel
2023-08-04 15:49       ` Alexander Lobakin
2023-08-04 13:47     ` Przemek Kitszel
2023-08-04 15:44       ` Alexander Lobakin
2023-08-07 12:42         ` Przemek Kitszel
2023-08-07 14:47           ` Kees Cook
2023-08-04 22:39       ` Kees Cook
2023-08-01 11:19 ` [RFC net-next 2/2] ice: make use of DECLARE_FLEX() in ice_switch.c Przemek Kitszel
2023-08-01 13:48   ` Alexander Lobakin
2023-08-01 14:36     ` Przemek Kitszel
2023-08-01 17:22       ` Alexander Lobakin
2023-08-01 22:35   ` Kees Cook

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).