From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02FAE43B21; Fri, 16 Feb 2024 01:33:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A300940284; Fri, 16 Feb 2024 01:33:47 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1CB0F4027C for ; Fri, 16 Feb 2024 01:33:46 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6C22820B2000; Thu, 15 Feb 2024 16:33:45 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6C22820B2000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1708043625; bh=yHTjhxmi5q1zzUZ/P4G/OfDbkZk3OJObxf2MTOV+Uzs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hj54KyWQ7cZfJnBOw6MKUBaC2we+6ctVEFTyj8tbEPe/st2hRCV5v1KhLeb7fed2S oDQxG8z6Y/YkIMZen0YGW04NJyZ5MwL1UNZ7DoR1KqmiwUAw2n6vYeT+kO3XuB5Ls/ q44Qknf7ls6M7EvUT0CbtUjXIbASlZNxlN4yF1V8= Date: Thu, 15 Feb 2024 16:33:45 -0800 From: Tyler Retzlaff To: Stephen Hemminger Cc: dev@dpdk.org, Morten =?iso-8859-1?Q?Br=F8rup?= Subject: Re: [PATCH v2 3/3] eal: replace out of bounds VLA with static_assert Message-ID: <20240216003345.GA24519@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20231111172153.57461-1-stephen@networkplumber.org> <20231113170605.408281-1-stephen@networkplumber.org> <20231113170605.408281-4-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231113170605.408281-4-stephen@networkplumber.org> User-Agent: Mutt/1.5.21 (2010-09-15) 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 ping 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. thanks! 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ørup > 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