DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v2 1/6] eal: add macros for local variable-length structure buffers
Date: Wed, 2 Dec 2026 09:16:43 +0000	[thread overview]
Message-ID: <aw_h-3GhuofqCMOh@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20261201113756.7b6d2613@phoenix.local>

On Tue, Dec 01, 2026 at 11:37:56AM -0800, Stephen Hemminger wrote:
> On Tue,  1 Dec 2026 18:22:44 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> > + */
> > +#define RTE_DEFINE_FLEX_BYTES(type, name, size) \
> > +	static_assert((size) >= sizeof(type), "buffer smaller than " RTE_STR(type)); \
> > +	union { \
> > +		uint8_t raw[size]; /* first member, so "{0}" zeroes the whole buffer */ \
> > +		type obj; \
> > +	} name ## _u = {0}; \
> > +	type * const name = &name ## _u.obj
> > +
> 
> Agree with Martin no VLA.

While these could be used with VLAs all use of this in this set is where
size is a compile-time constant, so that we don't have VLAs on stack. I'll
see if I can add a compile time assert to mandate fixed sizes here.
Checking equivalent DEFINE_RAW_FLEX in kernel, I see it similarly mandates
compile-time constant values for the size.

/Bruce

  reply	other threads:[~2026-12-02  9:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:09 [PATCH 27.03 0/6] eliminate unnecessary dynamic allocation Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 1/6] eal: add macros for local variable-length structure buffers Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 2/6] net/iavf: use stack storage for virtchnl messages Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 3/6] net/ice: use stack storage for function-local buffers Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 4/6] net/idpf: use stack storage for virtchnl messages Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 5/6] net/cpfl: use stack storage for function-local buffers Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 6/6] net/i40e: " Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 0/6] eliminate unnecessary dynamic allocation Bruce Richardson
2026-12-01 18:22   ` [PATCH v2 1/6] eal: add macros for local variable-length structure buffers Bruce Richardson
2026-12-01 19:29     ` Morten Brørup
2026-12-01 19:36       ` Stephen Hemminger
2026-12-01 19:37     ` Stephen Hemminger
2026-12-02  9:16       ` Bruce Richardson [this message]
2026-12-01 18:22   ` [PATCH v2 2/6] net/iavf: use stack storage for virtchnl messages Bruce Richardson
2026-12-01 18:22   ` [PATCH v2 3/6] net/ice: use stack storage for function-local buffers Bruce Richardson
2026-12-01 18:22   ` [PATCH v2 4/6] net/idpf: use stack storage for virtchnl messages Bruce Richardson
2026-12-01 18:22   ` [PATCH v2 5/6] net/cpfl: use stack storage for function-local buffers Bruce Richardson
2026-12-01 18:22   ` [PATCH v2 6/6] net/i40e: " Bruce Richardson
2026-12-02 10:18 ` [PATCH v3 0/6] net/intel: eliminate unnecessary dynamic allocation Bruce Richardson
2026-12-02 10:18   ` [PATCH v3 1/6] eal: add macros for local variable-length structure buffers Bruce Richardson
2026-12-02 10:18   ` [PATCH v3 2/6] net/iavf: use stack storage for virtchnl messages Bruce Richardson
2026-12-02 10:18   ` [PATCH v3 3/6] net/ice: use stack storage for function-local buffers Bruce Richardson
2026-12-02 10:18   ` [PATCH v3 4/6] net/idpf: use stack storage for virtchnl messages Bruce Richardson
2026-12-02 10:18   ` [PATCH v3 5/6] net/cpfl: use stack storage for function-local buffers Bruce Richardson
2026-12-02 10:18   ` [PATCH v3 6/6] net/i40e: " Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw_h-3GhuofqCMOh@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox