[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230801111923.118268-1-przemyslaw.kitszel@intel.com>
Date: Tue, 1 Aug 2023 13:19:21 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Kees Cook <keescook@...omium.org>
Cc: Jacob Keller <jacob.e.keller@...el.com>,
intel-wired-lan@...ts.osuosl.org,
netdev@...r.kernel.org,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>
Subject: [RFC net-next 0/2] introduce DECLARE_FLEX() macro
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
Powered by blists - more mailing lists