From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F6DE606A31A for ; Tue, 1 Dec 2026 19:29:51 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0422D402C3; Tue, 1 Dec 2026 20:29:50 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTPS id C0EC0402B8 for ; Tue, 1 Dec 2026 20:29:48 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 5F973201BD; Tue, 1 Dec 2026 20:29:48 +0100 (CET) Content-class: urn:content-classes:message X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v2 1/6] eal: add macros for local variable-length structure buffers X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Tue, 1 Dec 2026 20:29:46 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65B4A@smartserver.smartshare.dk> In-Reply-To: <20261201182249.2520829-2-bruce.richardson@intel.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v2 1/6] eal: add macros for local variable-length structure buffers Thread-Index: Ad2BwQdMwG1kev09RVmapwHGIy8D/gACPfkg References: <20261116160932.1006354-1-bruce.richardson@intel.com> <20261201182249.2520829-1-bruce.richardson@intel.com> <20261201182249.2520829-2-bruce.richardson@intel.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Bruce Richardson" , X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Tuesday, 1 December 2026 19.23 >=20 > Many drivers allocate small control-path messages, which consist of a > header structure followed by a variable-length array, using malloc and > free, which adds error handling and the risk of leaks on error paths. >=20 > Add RTE_DEFINE_FLEX and RTE_DEFINE_FLEX_BYTES macros to define such > buffers on the stack instead, (similar to equivalent macros in Linux > kernel). The buffer is a union of a byte array and the structure type, > giving correct alignment and type-safe access via a pointer, with the > byte array first so that zero-initialization covers the whole buffer. >=20 > Signed-off-by: Bruce Richardson > --- I thought we wanted to get rid of variable length arrays... Could this be implemented using alloca() instead?