From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1972AC48260 for ; Fri, 16 Feb 2024 07:48:37 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D85440284; Fri, 16 Feb 2024 08:48:36 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id EF40540266 for ; Fri, 16 Feb 2024 08:48:34 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id CA354206EF; Fri, 16 Feb 2024 08:48:34 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v2 3/3] eal: replace out of bounds VLA with static_assert X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Fri, 16 Feb 2024 08:48:31 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F221@smartserver.smartshare.dk> In-Reply-To: <20240216003345.GA24519@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v2 3/3] eal: replace out of bounds VLA with static_assert Thread-Index: Adpgb88N/uq7TNDkRd2Za+Wc3kkS7QAPBTjg References: <20231111172153.57461-1-stephen@networkplumber.org> <20231113170605.408281-1-stephen@networkplumber.org> <20231113170605.408281-4-stephen@networkplumber.org> <20240216003345.GA24519@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: , Cc: , "Tyler Retzlaff" , "Stephen Hemminger" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > Sent: Friday, 16 February 2024 01.34 >=20 > ping >=20 > i'd like to see this change go in asap since it is pre-requisite to > turning on -Wvla which explicitly caught use of non-constant > expressions > in the RTE_BUILD_BUG_ON() hiding bugs. >=20 > thanks! >=20 > On Mon, Nov 13, 2023 at 09:06:05AM -0800, Stephen Hemminger wrote: > > Both Gcc, clang and MSVC have better way to do compile time > > assertions rather than using out of bounds array access. > > The old method would fail if -Wvla is enabled because compiler > > can't determine size in that code. Also, the use of new > > _Static_assert will catch broken code that is passing non-constant > > expression to RTE_BUILD_BUG_ON(). > > > > Signed-off-by: Stephen Hemminger > > Acked-by: Morten Br=F8rup > > Acked-by: Tyler Retzlaff > > --- > > lib/eal/include/rte_common.h | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/lib/eal/include/rte_common.h > b/lib/eal/include/rte_common.h > > index c1ba32d00e47..bea7c0e57d5e 100644 > > --- a/lib/eal/include/rte_common.h > > +++ b/lib/eal/include/rte_common.h > > @@ -16,6 +16,7 @@ > > extern "C" { > > #endif > > > > +#include > > #include > > #include > > > > @@ -495,7 +496,7 @@ rte_is_aligned(const void * const __rte_restrict > ptr, const unsigned int align) > > /** > > * Triggers an error at compilation time if the condition is true. > > */ > > -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - > 2*!!(condition)])) > > +#define RTE_BUILD_BUG_ON(condition) static_assert(!(condition), > #condition) > > > > /*********** Cache line related macros ********/ > > > > -- > > 2.39.2 Reviewed-by: Morten Br=F8rup